diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-12-12 22:39:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-12-12 22:39:36 +0000 |
commit | 9c728dc4d8da89c73fcae74c9e72d7a83ffd7b6d (patch) | |
tree | e89a3acd2ddb4a993e1d6bac53c05628b24f4f2b /include/clang/Basic/SourceLocation.h | |
parent | 5e71124dabe8017f17ce8996e4161a202694e3e6 (diff) |
TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:
FullLoc.getManager().someMethod(FullLoc.getLocation());
instead we have:
FullLoc.someMethod();
Modified TextDiagnostics (and related classes) to use this short-hand.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceLocation.h')
-rw-r--r-- | include/clang/Basic/SourceLocation.h | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index 9ee1f308c5..9d03b649ef 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -17,9 +17,14 @@ #include <cassert> #include "llvm/Bitcode/SerializationFwd.h" +namespace llvm { +class MemoryBuffer; +} + namespace clang { class SourceManager; +class FileEntry; /// SourceLocation - This is a carefully crafted 32-bit identifier that encodes /// a full include stack, line and column number information for a position in @@ -206,25 +211,50 @@ public: /// that expect both objects. class FullSourceLoc { SourceLocation Loc; - const SourceManager* SrcMgr; + SourceManager* SrcMgr; public: // Creates a FullSourceLoc where isValid() returns false. explicit FullSourceLoc() : Loc(SourceLocation()), SrcMgr((SourceManager*) 0) {} - explicit FullSourceLoc(SourceLocation loc, const SourceManager& smgr) - : Loc(loc), SrcMgr(&smgr) { - assert (loc.isValid() && "SourceLocation must be valid!"); - } + explicit FullSourceLoc(SourceLocation loc, SourceManager& smgr) + : Loc(loc), SrcMgr(&smgr) {} bool isValid() const { return Loc.isValid(); } + bool isInvalid() const { return Loc.isInvalid(); } + + SourceLocation getLocation() const { return Loc; } - SourceLocation getSourceLocation() const { return Loc; } + SourceManager& getManager() { + assert (SrcMgr && "SourceManager is NULL."); + return *SrcMgr; + } const SourceManager& getManager() const { assert (SrcMgr && "SourceManager is NULL."); return *SrcMgr; } + + FullSourceLoc getLogicalLoc(); + FullSourceLoc getIncludeLoc(); + + unsigned getLineNumber(); + unsigned getColumnNumber(); + + const char *getCharacterData() const; + + const llvm::MemoryBuffer* getBuffer() const; + + const char* getSourceName() const; + const FileEntry* getFileEntryForLoc() const; + + bool operator==(const FullSourceLoc& RHS) const { + return SrcMgr == RHS.SrcMgr && Loc == RHS.Loc; + } + + bool operator!=(const FullSourceLoc& RHS) const { + return SrcMgr != RHS.SrcMgr || Loc != RHS.Loc; + } }; } // end namespace clang |