Closed
Description
D64087 appears to break some downstream code that relies on the expectation summarized in this unittest:
TEST(Regression, CXXDestructorDeclsShouldHaveWellFormedRanges) {
std::unique_ptr<ASTUnit> AST = buildASTFromCode(R"cpp(
template <typename T> struct Resource {
~Resource();
};
template <typename T>
Resource<T>::~Resource() {}
void instantiate_template() {
Resource<int> x;
}
)cpp",
"foo.cpp");
auto &SM = AST->getASTContext().getSourceManager();
auto Matches = match(
findAll(decl(hasDescendant(cxxDestructorDecl().bind("dtor")))),
*AST->getASTContext().getTranslationUnitDecl(), AST->getASTContext());
for (BoundNodes Match : Matches) {
const auto *D = Match.getNodeAs<CXXDestructorDecl>("dtor");
assert(D);
auto Range = D->getNameInfo().getSourceRange();
if (Range.getBegin() != Range.getEnd()) {
ASSERT_TRUE(
SM.isBeforeInTranslationUnit(Range.getBegin(), Range.getEnd()));
}
}
}
The test describes that for all CXXDestructorDecl
the corresponding getNameInfo()
should return a SourceRange
where the begin location is before then the end location (if they were not the same of course).
This test passes before commit 256a0b2 [clang] Correct source locations for instantiations of function templates.
(2023.09.12) but breaks after that.
IMO this expectation sounds right, and I believe it should hold.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status