Deleted Added
full compact
SourceManager.cpp (280031) SourceManager.cpp (283526)
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
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 // This can happen if a location is in a built-ins buffer.
2080 // But see PR5662.
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
2081 // Clear the lookup cache, it depends on a common location.
2082 IsBeforeInTUCache.clear();
2082 // Clear the lookup cache, it depends on a common location.
2083 IsBeforeInTUCache.clear();
2083 bool LIsBuiltins = strcmp("<built-in>",
2084 getBuffer(LOffs.first)->getBufferIdentifier()) == 0;
2085 bool RIsBuiltins = strcmp("<built-in>",
2086 getBuffer(ROffs.first)->getBufferIdentifier()) == 0;
2087 // built-in is before non-built-in
2088 if (LIsBuiltins != RIsBuiltins)
2089 return LIsBuiltins;
2090 assert(LIsBuiltins && RIsBuiltins &&
2091 "Non-built-in locations must be rooted in the main file");
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;
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");
2095}
2096
2097void SourceManager::PrintStats() const {
2098 llvm::errs() << "\n*** Source Manager Stats:\n";
2099 llvm::errs() << FileInfos.size() << " files mapped, " << MemBufferInfos.size()
2100 << " mem buffers mapped.\n";
2101 llvm::errs() << LocalSLocEntryTable.size() << " local SLocEntry's allocated ("
2102 << llvm::capacity_in_bytes(LocalSLocEntryTable)

--- 56 unchanged lines hidden ---
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 ---