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 | ee933e1cc2718bd829c4649d060fc9f686005990 (patch) | |
tree | 995931b45a0bda5087f4ee87e2b3050ba991edab /lib/Basic/SourceManager.cpp | |
parent | 7f040a9d817cd1c72b565e92abff473510bf9e1d (diff) | |
download | clang-ee933e1cc2718bd829c4649d060fc9f686005990.tar.gz |
Handle locations coming from macro instantiations properly in SourceManager::isBeforeInTranslationUnit().
Fixes rdar://8790245 and http://llvm.org/PR8821.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r-- | lib/Basic/SourceManager.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 54bdfd3166..409851f108 100644 --- a/lib/Basic/SourceManager.cpp +++ b/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); |