diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-08-17 00:31:18 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-08-17 00:31:18 +0000 |
commit | 37e59a10a7a537428e5997fd5896f5b89fd34e6b (patch) | |
tree | 458c03e85308a48d74f07bd8525f6dbad3cc3926 /include/clang/Basic/SourceManager.h | |
parent | d21683cdc0ff4217bfd98a9d8d0c1083b642caac (diff) |
Make SourceManager::isBeforeInTranslationUnit handle macro locations correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 1bf3278434..2ea19ebc4d 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -367,7 +367,11 @@ class IsBeforeInTranslationUnitCache { /// L/R QueryFID - These are the FID's of the cached query. If these match up /// with a subsequent query, the result can be reused. FileID LQueryFID, RQueryFID; - + + /// \brief True if LQueryFID was created before RQueryFID. This is used + /// to compare macro expansion locations. + bool IsLQFIDBeforeRQFID; + /// CommonFID - This is the file found in common between the two #include /// traces. It is the nearest common ancestor of the #include tree. FileID CommonFID; @@ -392,13 +396,27 @@ public: // use the #include loc in the common file. if (LQueryFID != CommonFID) LOffset = LCommonOffset; if (RQueryFID != CommonFID) ROffset = RCommonOffset; + + // It is common for multiple macro expansions to be "included" from the same + // location (expansion location), in which case use the order of the FileIDs + // to determine which came first. + if (LOffset == ROffset && LQueryFID != CommonFID && RQueryFID != CommonFID) + return IsLQFIDBeforeRQFID; + return LOffset < ROffset; } // Set up a new query. - void setQueryFIDs(FileID LHS, FileID RHS) { + void setQueryFIDs(FileID LHS, FileID RHS, bool isLFIDBeforeRFID) { + assert(LHS != RHS); LQueryFID = LHS; RQueryFID = RHS; + IsLQFIDBeforeRQFID = isLFIDBeforeRFID; + } + + void clear() { + LQueryFID = RQueryFID = FileID(); + IsLQFIDBeforeRQFID = false; } void setCommonLoc(FileID commonFID, unsigned lCommonOffset, |