This crash is basically caused by calling
`ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments
`RepresentativeLocForDecl` and `CommentsInTheFile` refering to different
files. A reduced reproducer is provided in this patch.
After the source locations for instantiations of funtion template are
corrected in the commit 256a0b298c, the
variable `CommitsInThisFile` in the function
`ASTContext::attachCommentsToJustParsedDecls` would refer to the source
file rather than the header file for implicit function template
instantiation. Therefore, in the first loop in
`ASTContext::attachCommentsToJustParsedDecls`, `D` should also be
adjusted for relevant scenarios like the second loop.
Fixes #67979
Fixes #68524
Fixes #70550
31 lines
514 B
C++
31 lines
514 B
C++
// 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
|