From: Richard Smith Date: Fri, 14 Mar 2014 22:07:27 +0000 (+0000) Subject: Call RequireCompleteType when performing ADL even if the type is already X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61377c32bafe9ddbf4099d90f9ba7454ca0829d6;p=clang Call RequireCompleteType when performing ADL even if the type is already complete. We hook into this check from a couple of other places (modules, debug info) so it's not OK to elide the check if the type was already complete. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203978 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index b3766a8c11..7ac10d38eb 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -2027,6 +2027,10 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, // Add the class itself. If we've already seen this class, we don't // need to visit base classes. + // + // FIXME: That's not correct, we may have added this class only because it + // was the enclosing class of another class, and in that case we won't have + // added its base classes yet. if (!Result.Classes.insert(Class)) return; @@ -2053,12 +2057,8 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, } // Only recurse into base classes for complete types. - if (!Class->hasDefinition()) { - QualType type = Result.S.Context.getTypeDeclType(Class); - if (Result.S.RequireCompleteType(Result.InstantiationLoc, type, - /*no diagnostic*/ 0)) - return; - } + if (!Class->hasDefinition()) + return; // Add direct and indirect base classes along with their associated // namespaces. @@ -2150,6 +2150,8 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) { // classes. Its associated namespaces are the namespaces in // which its associated classes are defined. case Type::Record: { + Result.S.RequireCompleteType(Result.InstantiationLoc, QualType(T, 0), + /*no diagnostic*/ 0); CXXRecordDecl *Class = cast(cast(T)->getDecl()); addAssociatedClassesAndNamespaces(Result, Class); diff --git a/test/CodeGenCXX/debug-info-class-limited.cpp b/test/CodeGenCXX/debug-info-class-limited.cpp index 9bf295e9b9..30abd2d89a 100644 --- a/test/CodeGenCXX/debug-info-class-limited.cpp +++ b/test/CodeGenCXX/debug-info-class-limited.cpp @@ -24,7 +24,7 @@ foo *bar(foo *a) { } namespace test1 { -// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [decl] +// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def] struct foo { }; diff --git a/test/CodeGenCXX/debug-info-limited.cpp b/test/CodeGenCXX/debug-info-limited.cpp index 54a2424fdd..294d1f6b6d 100644 --- a/test/CodeGenCXX/debug-info-limited.cpp +++ b/test/CodeGenCXX/debug-info-limited.cpp @@ -11,8 +11,7 @@ A *foo (A* x) { return a; } -// Verify that we're not emitting a full definition of B in limit debug mode. -// CHECK: ; [ DW_TAG_class_type ] [B] {{.*}} [decl] +// CHECK: ; [ DW_TAG_class_type ] [B] {{.*}} [def] class B { public: