]> granicus.if.org Git - clang/commitdiff
PR16995: Failing to associate static members with their enclosing class
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 28 Aug 2013 17:27:13 +0000 (17:27 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 28 Aug 2013 17:27:13 +0000 (17:27 +0000)
In the transition from declaration (with some members) to definition, we
were overwriting the list of members with the empty list when attaching
template parameters.

The fix is in llvm::DICompositeType::addMember (along with asserts that
cause this bug to be covered by existing Clang test cases), including
adding some asserts to catch this sort of issue which found issues fixed
in this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189494 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index 153f285d493bb7804e7eb06c76fff66574103615..09202bbbb83420d55a005525f76769a71df100f1 100644 (file)
@@ -1122,17 +1122,14 @@ CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit,
   // the functions.
   for(DeclContext::decl_iterator I = RD->decls_begin(),
         E = RD->decls_end(); I != E; ++I) {
-    Decl *D = *I;
-    if (D->isImplicit())
-      continue;
-
-    if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
+    if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*I)) {
       // Reuse the existing member function declaration if it exists
       llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
           SPCache.find(Method->getCanonicalDecl());
-      if (MI == SPCache.end())
-        EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy));
-      else
+      if (MI == SPCache.end()) {
+        if (!Method->isImplicit())
+          EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy));
+      } else
         EltTys.push_back(MI->second);
     }
   }