aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceLocation.h
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2011-01-18 02:00:16 +0000
committerJeffrey Yasskin <jyasskin@google.com>2011-01-18 02:00:16 +0000
commitdec0984fce504a39a7f085774fb67cfd9957be58 (patch)
tree55173b9ff3c2a9fdc4be568145ce61ad5cb8f05e /include/clang/Basic/SourceLocation.h
parentfb1e3bc29b667f4275e1d5a43d64ec173f4f9a7d (diff)
Fix warnings found by gcc-4.6, from -Wunused-but-set-variable and
-Wint-to-pointer-cast. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceLocation.h')
-rw-r--r--include/clang/Basic/SourceLocation.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h
index 74f762bd90..605c4bbafc 100644
--- a/include/clang/Basic/SourceLocation.h
+++ b/include/clang/Basic/SourceLocation.h
@@ -130,6 +130,22 @@ public:
return X;
}
+ /// getPtrEncoding - When a SourceLocation itself cannot be used, this returns
+ /// an (opaque) pointer encoding for it. This should only be passed
+ /// to SourceLocation::getFromPtrEncoding, it should not be inspected
+ /// directly.
+ void* getPtrEncoding() const {
+ // Double cast to avoid a warning "cast to pointer from integer of different
+ // size".
+ return (void*)(uintptr_t)getRawEncoding();
+ }
+
+ /// getFromPtrEncoding - Turn a pointer encoding of a SourceLocation object
+ /// into a real SourceLocation.
+ static SourceLocation getFromPtrEncoding(void *Encoding) {
+ return getFromRawEncoding((unsigned)(uintptr_t)Encoding);
+ }
+
void print(llvm::raw_ostream &OS, const SourceManager &SM) const;
void dump(const SourceManager &SM) const;
};
@@ -369,7 +385,7 @@ namespace llvm {
class PointerLikeTypeTraits<clang::SourceLocation> {
public:
static inline void *getAsVoidPointer(clang::SourceLocation L) {
- return (void*)L.getRawEncoding();
+ return L.getPtrEncoding();
}
static inline clang::SourceLocation getFromVoidPointer(void *P) {
return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P);