aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/DeclBase.h21
-rw-r--r--include/clang/AST/Type.h2
-rw-r--r--include/clang/Parse/Ownership.h2
-rw-r--r--lib/AST/DeclBase.cpp2
-rw-r--r--lib/AST/DeclSerialization.cpp2
5 files changed, 23 insertions, 6 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 0f9fb4569e..e98a378502 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -40,6 +40,23 @@ class LinkageSpecDecl;
class BlockDecl;
class DeclarationName;
class CompoundStmt;
+}
+
+namespace llvm {
+// DeclContext* is only 4-byte aligned on 32-bit systems.
+template<>
+ class PointerLikeTypeTraits<clang::DeclContext*> {
+ typedef clang::DeclContext* PT;
+public:
+ static inline void *getAsVoidPointer(PT P) { return P; }
+ static inline PT getFromVoidPointer(void *P) {
+ return static_cast<PT>(P);
+ }
+ enum { NumLowBitsAvailable = 2 };
+};
+}
+
+namespace clang {
/// Decl - This represents one declaration (or definition), e.g. a variable,
/// typedef, function, struct, etc.
@@ -109,7 +126,7 @@ private:
/// }
/// void A::f(); // SemanticDC == namespace 'A'
/// // LexicalDC == global namespace
- llvm::PointerIntPair<void*, 1, bool> DeclCtx;
+ llvm::PointerIntPair<DeclContext*, 1, bool> DeclCtx;
struct MultipleDC {
DeclContext *SemanticDC;
@@ -120,7 +137,7 @@ private:
inline bool isOutOfSemaDC() const { return DeclCtx.getInt() != 0; }
inline MultipleDC *getMultipleDC() const {
assert(isOutOfSemaDC() && "Invalid accessor");
- return static_cast<MultipleDC*>(DeclCtx.getPointer());
+ return reinterpret_cast<MultipleDC*>(DeclCtx.getPointer());
}
inline DeclContext *getSemanticDC() const {
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index aa0861808a..ea1b496cd3 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -234,7 +234,7 @@ public:
return clang::QualType::getFromOpaquePtr(P);
}
// CVR qualifiers go in low bits.
- static inline unsigned getNumLowBitsAvailable() { return 0; }
+ enum { NumLowBitsAvailable = 0 };
};
} // end namespace llvm
diff --git a/include/clang/Parse/Ownership.h b/include/clang/Parse/Ownership.h
index 362220fc6d..50bc5aee12 100644
--- a/include/clang/Parse/Ownership.h
+++ b/include/clang/Parse/Ownership.h
@@ -57,7 +57,7 @@ namespace llvm {
static inline clang::OpaquePtr<UID> getFromVoidPointer(void *P) {
return clang::OpaquePtr<UID>::make(P);
}
- static inline unsigned getNumLowBitsAvailable() { return 3; }
+ enum { NumLowBitsAvailable = 3 };
};
}
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index bc7ac569fc..9ab269d305 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -141,7 +141,7 @@ void Decl::setLexicalDeclContext(DeclContext *DC) {
MultipleDC *MDC = new MultipleDC();
MDC->SemanticDC = getDeclContext();
MDC->LexicalDC = DC;
- DeclCtx.setPointer(MDC);
+ DeclCtx.setPointer(reinterpret_cast<DeclContext*>(MDC));
DeclCtx.setInt(true);
} else {
getMultipleDC()->LexicalDC = DC;
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index 7ac7ac49b0..965874502d 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -139,7 +139,7 @@ Decl* Decl::Create(Deserializer& D, ASTContext& C) {
}
else {
MultipleDC *MDC = new MultipleDC();
- Dcl->DeclCtx.setPointer(MDC);
+ Dcl->DeclCtx.setPointer(reinterpret_cast<DeclContext*>(MDC));
Dcl->DeclCtx.setInt(true);
// Allow back-patching. Observe that we register the variable of the
// *object* for back-patching. Its actual value will get filled in later.