]> granicus.if.org Git - clang/commitdiff
Attaching comments to declarations: ignore implicit decls. Decl::isImplicit()
authorDmitri Gribenko <gribozavr@gmail.com>
Mon, 20 Aug 2012 22:36:31 +0000 (22:36 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Mon, 20 Aug 2012 22:36:31 +0000 (22:36 +0000)
does not return true for all implicit decls currently.

This should fix PR13634 for now, but Decl::isImplicit() should be fixed, too.

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

lib/AST/ASTContext.cpp

index c02132329e6df0521a8b171b1cb31c1146befd90..0452730201b5891369d77556a590804f7bc74480 100644 (file)
@@ -67,11 +67,29 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
     return NULL;
 
   // User can not attach documentation to implicit instantiations.
+  // FIXME: all these implicit instantiations shoud be marked as implicit
+  // declarations and get caught by condition above.
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
       return NULL;
   }
 
+  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+    if (VD->isStaticDataMember() &&
+        VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+      return NULL;
+  }
+
+  if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(D)) {
+    if (CRD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+      return NULL;
+  }
+
+  if (const EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
+    if (ED->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+      return NULL;
+  }
+
   // TODO: handle comments for function parameters properly.
   if (isa<ParmVarDecl>(D))
     return NULL;