diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-12-12 18:16:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-12-12 18:16:46 +0000 |
commit | a9793ed6a77946c988ee38035baf4cde6ff2e864 (patch) | |
tree | 50f6517bfbe65cf2da8cde866e72237b49c82cb5 /include/clang/Basic/SourceLocation.h | |
parent | 609e4c72d9190a57636836d658b3563d9a9545ae (diff) |
Added class FullContextSourceLocation: a tuple class that
contains both a SourceLocation and its associated
SourceManager. This class is useful for argument passing to
functions that expect both objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44942 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceLocation.h')
-rw-r--r-- | include/clang/Basic/SourceLocation.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index c25528b7e9..145d590046 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -18,6 +18,8 @@ #include "llvm/Bitcode/SerializationFwd.h" namespace clang { + +class SourceManager; /// SourceLocation - This is a carefully crafted 32-bit identifier that encodes /// a full include stack, line and column number information for a position in @@ -199,6 +201,35 @@ public: static SourceRange ReadVal(llvm::Deserializer& D); }; +/// FullContextSourceLocation - A tuple containing both a SourceLocation +/// and its associated SourceManager. Useful for argument passing to functions +/// that expect both objects. +class FullContextSourceLocation { + SourceLocation Loc; + SourceManager* SrcMgr; +public: + explicit FullContextSourceLocation(SourceLocation loc) + : Loc(loc), SrcMgr(NULL) {} + + explicit FullContextSourceLocation(SourceLocation loc, SourceManager& smgr) + : Loc(loc), SrcMgr(&smgr) {} + + bool isValid() { return Loc.isValid(); } + + SourceLocation getSourceLocation() const { return Loc; } + operator SourceLocation() const { return Loc; } + + SourceManager& getSourceManager() { + assert (SrcMgr && "SourceManager is NULL."); + return *SrcMgr; + } + + const SourceManager& getSourceManager() const { + assert (SrcMgr && "SourceManager is NULL."); + return *SrcMgr; + } +}; + } // end namespace clang #endif |