summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-25 15:59:44 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-25 15:59:44 +0000
commitdfcad11842c24013adc50857d820ebc8b23ed3d5 (patch)
treebba60333fd4802ea92b8fca60221f0ccbc95108f /clang/lib
parent8a6555332f80fc6395a0f439239f63868dbb8681 (diff)
downloadbcm5719-llvm-dfcad11842c24013adc50857d820ebc8b23ed3d5.tar.gz
bcm5719-llvm-dfcad11842c24013adc50857d820ebc8b23ed3d5.zip
Predicate to detect when a RecordDecl is really the injected-class-name
llvm-svn: 67687
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Decl.cpp5
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 321ccf34f96..15a20bd050c 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -491,6 +491,11 @@ void RecordDecl::Destroy(ASTContext& C) {
TagDecl::Destroy(C);
}
+bool RecordDecl::isInjectedClassName() const {
+ return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
+ cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
+}
+
/// completeDefinition - Notes that the definition of this type is now
/// complete.
void RecordDecl::completeDefinition(ASTContext& C) {
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b76126aa8fc..fd89507645a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3398,6 +3398,8 @@ void Sema::ActOnTagStartDefinition(Scope *S, DeclTy *TagD) {
Record->getIdentifier(), Record);
InjectedClassName->setImplicit();
PushOnScopeChains(InjectedClassName, S);
+ assert(InjectedClassName->isInjectedClassName() &&
+ "Broken injected-class-name");
}
}
}
OpenPOWER on IntegriCloud