summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-12-24 02:53:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-12-24 02:53:53 +0000
commit338f9aaab212c5b84e1efbea6a1514e265721135 (patch)
treef85757769c4a4bd891c3644050d0fc03a547864a /clang/lib/Basic/SourceManager.cpp
parent53fa71476d0539b031a8f91232607f5ca8f182e5 (diff)
downloadbcm5719-llvm-338f9aaab212c5b84e1efbea6a1514e265721135.tar.gz
bcm5719-llvm-338f9aaab212c5b84e1efbea6a1514e265721135.zip
Handle locations coming from macro instantiations properly in SourceManager::isBeforeInTranslationUnit().
Fixes rdar://8790245 and http://llvm.org/PR8821. llvm-svn: 122536
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 54bdfd31660..409851f108c 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1198,6 +1198,13 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
if (LHS == RHS)
return false;
+ // If both locations are macro instantiations, the order of their offsets
+ // reflect the order that the tokens, pointed to by these locations, were
+ // instantiated (during parsing each token that is instantiated by a macro,
+ // expands the SLocEntries).
+ if (LHS.isMacroID() && RHS.isMacroID())
+ return LHS.getOffset() < RHS.getOffset();
+
std::pair<FileID, unsigned> LOffs = getDecomposedLoc(LHS);
std::pair<FileID, unsigned> ROffs = getDecomposedLoc(RHS);
OpenPOWER on IntegriCloud