Deleted Added
sdiff udiff text old ( 280031 ) new ( 283526 )
full compact
1//===--- SourceManager.cpp - Track and cache source files -----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 2062 unchanged lines hidden (view full) ---

2071
2072 // If we exited because we found a nearest common ancestor, compare the
2073 // locations within the common file and cache them.
2074 if (LOffs.first == ROffs.first) {
2075 IsBeforeInTUCache.setCommonLoc(LOffs.first, LOffs.second, ROffs.second);
2076 return IsBeforeInTUCache.getCachedResult(LOffs.second, ROffs.second);
2077 }
2078
2079 // If we arrived here, the location is either in a built-ins buffer or
2080 // associated with global inline asm. PR5662 and PR22576 are examples.
2081
2082 // Clear the lookup cache, it depends on a common location.
2083 IsBeforeInTUCache.clear();
2084 llvm::MemoryBuffer *LBuf = getBuffer(LOffs.first);
2085 llvm::MemoryBuffer *RBuf = getBuffer(ROffs.first);
2086 bool LIsBuiltins = strcmp("<built-in>", LBuf->getBufferIdentifier()) == 0;
2087 bool RIsBuiltins = strcmp("<built-in>", RBuf->getBufferIdentifier()) == 0;
2088 // Sort built-in before non-built-in.
2089 if (LIsBuiltins || RIsBuiltins) {
2090 if (LIsBuiltins != RIsBuiltins)
2091 return LIsBuiltins;
2092 // Both are in built-in buffers, but from different files. We just claim that
2093 // lower IDs come first.
2094 return LOffs.first < ROffs.first;
2095 }
2096 bool LIsAsm = strcmp("<inline asm>", LBuf->getBufferIdentifier()) == 0;
2097 bool RIsAsm = strcmp("<inline asm>", RBuf->getBufferIdentifier()) == 0;
2098 // Sort assembler after built-ins, but before the rest.
2099 if (LIsAsm || RIsAsm) {
2100 if (LIsAsm != RIsAsm)
2101 return RIsAsm;
2102 assert(LOffs.first == ROffs.first);
2103 return false;
2104 }
2105 llvm_unreachable("Unsortable locations found");
2106}
2107
2108void SourceManager::PrintStats() const {
2109 llvm::errs() << "\n*** Source Manager Stats:\n";
2110 llvm::errs() << FileInfos.size() << " files mapped, " << MemBufferInfos.size()
2111 << " mem buffers mapped.\n";
2112 llvm::errs() << LocalSLocEntryTable.size() << " local SLocEntry's allocated ("
2113 << llvm::capacity_in_bytes(LocalSLocEntryTable)

--- 56 unchanged lines hidden ---