Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,11 @@ void ASTContext::attachCommentsToJustParsedDecls(ArrayRef<Decl *> Decls,
return;

FileID File;
for (Decl *D : Decls) {
for (const Decl *D : Decls) {
if (D->isInvalidDecl())
continue;

D = &adjustDeclToTemplate(*D);
SourceLocation Loc = D->getLocation();
if (Loc.isValid()) {
// See if there are any new comments that are not attached to a decl.
Expand Down
30 changes: 30 additions & 0 deletions clang/test/AST/ast-crash-doc-function-template.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// RUN: rm -rf %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -x c++ -Wdocumentation -fsyntax-only -ast-dump-all %t/t.cpp

//--- t.h
/// MyClass in the header file
class MyClass {
public:
template <typename T>
void Foo() const;

/// Bar
void Bar() const;
};

//--- t.cpp
#include "t.h"

/// MyClass::Bar: Foo<int>() is implicitly instantiated and called here.
void MyClass::Bar() const {
Foo<int>();
}

/// MyClass::Foo
template <typename T>
void MyClass::Foo() const {
}

// CHECK: TranslationUnitDecl