[cfe-commits] r97767 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp
Douglas Gregor
dgregor at apple.com
Thu Mar 4 16:26:45 PST 2010
Author: dgregor
Date: Thu Mar 4 18:26:45 2010
New Revision: 97767
URL: http://llvm.org/viewvc/llvm-project?rev=97767&view=rev
Log:
When we invalidate a declaration, make it public, so that it doesn't
trigger access control or one of the many assertions we have for valid
access specifiers.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=97767&r1=97766&r2=97767&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu Mar 4 18:26:45 2010
@@ -268,7 +268,7 @@
/// setInvalidDecl - Indicates the Decl had a semantic error. This
/// allows for graceful error recovery.
- void setInvalidDecl(bool Invalid = true) { InvalidDecl = Invalid; }
+ void setInvalidDecl(bool Invalid = true);
bool isInvalidDecl() const { return (bool) InvalidDecl; }
/// isImplicit - Indicates whether the declaration was implicitly
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=97767&r1=97766&r2=97767&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Mar 4 18:26:45 2010
@@ -46,6 +46,16 @@
}
}
+void Decl::setInvalidDecl(bool Invalid) {
+ InvalidDecl = Invalid;
+ if (Invalid) {
+ // Defensive maneuver for ill-formed code: we're likely not to make it to
+ // a point where we set the access specifier, so default it to "public"
+ // to avoid triggering asserts elsewhere in the front end.
+ setAccess(AS_public);
+ }
+}
+
const char *DeclContext::getDeclKindName() const {
switch (DeclKind) {
default: assert(0 && "Declaration context not in DeclNodes.def!");
More information about the cfe-commits
mailing list