[cfe-commits] r80438 - in /cfe/trunk/lib/AST: DeclBase.cpp DeclPrinter.cpp

Anders Carlsson andersca at mac.com
Sat Aug 29 13:47:47 PDT 2009


Author: andersca
Date: Sat Aug 29 15:47:47 2009
New Revision: 80438

URL: http://llvm.org/viewvc/llvm-project?rev=80438&view=rev
Log:
Add a workaround for decls that come from friend decls pointing to undeclared classes.

Modified:
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/AST/DeclPrinter.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=80438&r1=80437&r2=80438&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sat Aug 29 15:47:47 2009
@@ -379,8 +379,18 @@
 
 #ifndef NDEBUG
 void Decl::CheckAccessDeclContext() const {
-  assert((Access != AS_none || isa<TranslationUnitDecl>(this) ||
-          !isa<CXXRecordDecl>(getDeclContext())) &&
+  // If the decl is the toplevel translation unit or if we're not in a
+  // record decl context, we don't need to check anything.
+  if (isa<TranslationUnitDecl>(this) ||
+      !isa<CXXRecordDecl>(getDeclContext()))
+    return;
+  
+  // FIXME: This check should not be necessary - If a friend decl refers to an
+  // undeclared decl, then that decl shouldn't be in any decl context.
+  if (getFriendObjectKind() == FOK_Undeclared)
+    return;
+  
+  assert(Access != AS_none && 
          "Access specifier is AS_none inside a record decl");
 }
 

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=80438&r1=80437&r2=80438&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Sat Aug 29 15:47:47 2009
@@ -202,7 +202,10 @@
 
     if (PrintAccess) {
       AccessSpecifier AS = D->getAccess();
-      if (AS != CurAS) {
+
+      if (AS != CurAS && 
+          // FIXME: This check shouldn't be necessary.
+          D->getFriendObjectKind() == Decl::FOK_Undeclared) {
         Print(AS);
         Out << ":\n";
         CurAS = AS;





More information about the cfe-commits mailing list