summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-10 23:38:47 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-10 23:38:47 +0000
commit38988d7ee0b8ae70331a90e90c706ba0524679f3 (patch)
treea742d34fd2de476723ead254e315a4d64ce6a3a0 /clang/lib/CodeGen/CodeGenModule.h
parent8d6298b2724342240abefafd01621942fe554812 (diff)
downloadbcm5719-llvm-38988d7ee0b8ae70331a90e90c706ba0524679f3.tar.gz
bcm5719-llvm-38988d7ee0b8ae70331a90e90c706ba0524679f3.zip
Add stricter GlobalDecl constructors.
llvm-svn: 81480
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 607f2a172c2..d5b0bfa6a8d 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -70,23 +70,31 @@ namespace CodeGen {
/// GlobalDecl - represents a global declaration. This can either be a
/// CXXConstructorDecl and the constructor type (Base, Complete).
/// a CXXDestructorDecl and the destructor type (Base, Complete) or
-// a regular VarDecl or a FunctionDecl.
+/// a VarDecl, a FunctionDecl or a BlockDecl.
class GlobalDecl {
- llvm::PointerIntPair<const ValueDecl*, 2> Value;
+ llvm::PointerIntPair<const Decl*, 2> Value;
+ void init(const Decl *D) {
+ assert(!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!");
+ assert(!isa<CXXDestructorDecl>(D) && "Use other ctor with dtor decls!");
+ assert(isa<VarDecl>(D) || isa<FunctionDecl>(D)
+ && "Invalid decl type passed to GlobalDecl ctor!");
+
+ Value.setPointer(D);
+ }
+
public:
GlobalDecl() {}
- explicit GlobalDecl(const ValueDecl *VD) : Value(VD, 0) {
- assert(!isa<CXXConstructorDecl>(VD) && "Use other ctor with ctor decls!");
- assert(!isa<CXXDestructorDecl>(VD) && "Use other ctor with dtor decls!");
- }
+ GlobalDecl(const VarDecl *D) { init(D);}
+ GlobalDecl(const FunctionDecl *D) { init(D); }
+
GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type)
: Value(D, Type) {}
GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type)
: Value(D, Type) {}
- const ValueDecl *getDecl() const { return Value.getPointer(); }
+ const Decl *getDecl() const { return Value.getPointer(); }
CXXCtorType getCtorType() const {
assert(isa<CXXConstructorDecl>(getDecl()) && "Decl is not a ctor!");
OpenPOWER on IntegriCloud