diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-12-24 02:53:53 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-12-24 02:53:53 +0000 |
commit | 338f9aaab212c5b84e1efbea6a1514e265721135 (patch) | |
tree | f85757769c4a4bd891c3644050d0fc03a547864a /clang/lib/Basic/SourceManager.cpp | |
parent | 53fa71476d0539b031a8f91232607f5ca8f182e5 (diff) | |
download | bcm5719-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.cpp | 7 |
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); |