[LLVMbugs] [Bug 13634] New: -Wdocumentation assertion when dealing with implicit instantiations of functions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 17 16:23:36 PDT 2012


             Bug #: 13634
           Summary: -Wdocumentation assertion when dealing with implicit
                    instantiations of functions
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dgregor at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

terfin:clang dgregor$ cat t.cpp 

template<typename T>
struct X {
  /// \brief Blarg
  X(T) {}

void bar() {
  X<int> xi(5);

/// unattached

terfin:clang dgregor$ clang -Wdocumentation t.cpp 
Assertion failed: (DeclOrParsedComment.isNull()), function setDecl, file
line 66.

The issue is, essentially, that the implicit instantiation picks up a comment
that is already associated with the member function from which it was

This little hack:

Index: lib/AST/ASTContext.cpp
--- lib/AST/ASTContext.cpp    (revision 161762)
+++ lib/AST/ASTContext.cpp    (working copy)
@@ -195,6 +195,12 @@
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     if (const FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate())
       D = FTD;
+    else if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+      if (FD->isFunctionTemplateSpecialization())
+        D = FD->getPrimaryTemplate();
+      else if (FunctionDecl *MemFD = FD->getInstantiatedFromMemberFunction())
+        D = MemFD;
+    }
   } else if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
     if (const ClassTemplateDecl *CTD = RD->getDescribedClassTemplate())
       D = CTD;

Seems to fix the immediate problem, but there will likely also be issues with
class template specializations and instantiations, as well as enums and static
data members, so we need a more comprehensive approach.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list