[llvm-branch-commits] [cfe-branch] r232565 - Merging r232389:
Joerg Sonnenberger
joerg at bec.de
Tue Mar 17 16:24:18 PDT 2015
Author: joerg
Date: Tue Mar 17 18:24:18 2015
New Revision: 232565
URL: http://llvm.org/viewvc/llvm-project?rev=232565&view=rev
Log:
Merging r232389:
Global inline assembler blocks are merged before parsing, so no specific
location data is available. If pragma handling wants to look up the
position, it finds the LLVM buffer and wants to compare it with the
special built-in buffer, failing badly. Extend to the special handling
of the built-in buffer to also check for the inline asm buffer. Expect
only a single asm buffer. Sort it between the built-in buffers and the
normal file buffers.
Fixes the assert part of PR 22576.
Added:
cfe/branches/release_36/test/CodeGen/invalid_global_asm.c
- copied unchanged from r232389, cfe/trunk/test/CodeGen/invalid_global_asm.c
Modified:
cfe/branches/release_36/ (props changed)
cfe/branches/release_36/lib/Basic/SourceManager.cpp
Propchange: cfe/branches/release_36/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 17 18:24:18 2015
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:226008,226049,226136,226282,226382,226384,226624,226707,226754,226863,226877,227062,227088,227220,227251,227278,227295,227368,227393,227861,227979,228053,228464,228785,228792,229408,229719,230255,231245,231280,231986
+/cfe/trunk:226008,226049,226136,226282,226382,226384,226624,226707,226754,226863,226877,227062,227088,227220,227251,227278,227295,227368,227393,227861,227979,228053,228464,228785,228792,229408,229719,230255,231245,231280,231986,232389
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_36/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/lib/Basic/SourceManager.cpp?rev=232565&r1=232564&r2=232565&view=diff
==============================================================================
--- cfe/branches/release_36/lib/Basic/SourceManager.cpp (original)
+++ cfe/branches/release_36/lib/Basic/SourceManager.cpp Tue Mar 17 18:24:18 2015
@@ -2076,22 +2076,33 @@ bool SourceManager::isBeforeInTranslatio
return IsBeforeInTUCache.getCachedResult(LOffs.second, ROffs.second);
}
- // This can happen if a location is in a built-ins buffer.
- // But see PR5662.
+ // If we arrived here, the location is either in a built-ins buffer or
+ // associated with global inline asm. PR5662 and PR22576 are examples.
+
// Clear the lookup cache, it depends on a common location.
IsBeforeInTUCache.clear();
- bool LIsBuiltins = strcmp("<built-in>",
- getBuffer(LOffs.first)->getBufferIdentifier()) == 0;
- bool RIsBuiltins = strcmp("<built-in>",
- getBuffer(ROffs.first)->getBufferIdentifier()) == 0;
- // built-in is before non-built-in
- if (LIsBuiltins != RIsBuiltins)
- return LIsBuiltins;
- assert(LIsBuiltins && RIsBuiltins &&
- "Non-built-in locations must be rooted in the main file");
- // Both are in built-in buffers, but from different files. We just claim that
- // lower IDs come first.
- return LOffs.first < ROffs.first;
+ llvm::MemoryBuffer *LBuf = getBuffer(LOffs.first);
+ llvm::MemoryBuffer *RBuf = getBuffer(ROffs.first);
+ bool LIsBuiltins = strcmp("<built-in>", LBuf->getBufferIdentifier()) == 0;
+ bool RIsBuiltins = strcmp("<built-in>", RBuf->getBufferIdentifier()) == 0;
+ // Sort built-in before non-built-in.
+ if (LIsBuiltins || RIsBuiltins) {
+ if (LIsBuiltins != RIsBuiltins)
+ return LIsBuiltins;
+ // Both are in built-in buffers, but from different files. We just claim that
+ // lower IDs come first.
+ return LOffs.first < ROffs.first;
+ }
+ bool LIsAsm = strcmp("<inline asm>", LBuf->getBufferIdentifier()) == 0;
+ bool RIsAsm = strcmp("<inline asm>", RBuf->getBufferIdentifier()) == 0;
+ // Sort assembler after built-ins, but before the rest.
+ if (LIsAsm || RIsAsm) {
+ if (LIsAsm != RIsAsm)
+ return RIsAsm;
+ assert(LOffs.first == ROffs.first);
+ return false;
+ }
+ llvm_unreachable("Unsortable locations found");
}
void SourceManager::PrintStats() const {
More information about the llvm-branch-commits
mailing list