aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-23 22:01:48 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-23 22:01:48 +0000
commit2aa03d588bd2d3c73deb662880c2244bf2e384b9 (patch)
treea17a5a972bb4fae2c7ca81250debc625a9b2a1de /include/clang/Basic/SourceManager.h
parent34d25d85d6abead0fa6337080449609a2a4f4404 (diff)
Introduce SourceManager::ísBeforeInTranslationUnit() which can compare 2 source locations and determine which one comes before the other, relative to the translation unit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74014 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index bcfb83b894..249ca89f71 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -326,6 +326,11 @@ class SourceManager {
// Statistics for -print-stats.
mutable unsigned NumLinearScans, NumBinaryProbes;
+ // Cache results for the isBeforeInTranslationUnit method.
+ mutable FileID LastLFIDForBeforeTUCheck;
+ mutable FileID LastRFIDForBeforeTUCheck;
+ mutable bool LastResForBeforeTUCheck;
+
// SourceManager doesn't support copy construction.
explicit SourceManager(const SourceManager&);
void operator=(const SourceManager&);
@@ -637,6 +642,11 @@ public:
SourceLocation getLocation(const FileEntry *SourceFile,
unsigned Line, unsigned Col) const;
+ /// \brief Determines the order of 2 source locations in the translation unit.
+ ///
+ /// \returns true if LHS source location comes before RHS, false otherwise.
+ bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const;
+
// Iterators over FileInfos.
typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>
::const_iterator fileinfo_iterator;