Date: Sat, 6 Apr 2024 20:18:37 GMT From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: dc36515b6283 - main - Merge commit 5f4ee5a2dfa9 from llvm-project (by Shanzhi): Message-ID: <202404062018.436KIbAO030010@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=dc36515b628331e03ac8c23a6749f7f3eb1ebec8 commit dc36515b628331e03ac8c23a6749f7f3eb1ebec8 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-02-05 09:16:17 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-04-06 20:14:02 +0000 Merge commit 5f4ee5a2dfa9 from llvm-project (by Shanzhi): [Clang][AST] Fix a crash on attaching doc comments (#78716) 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 256a0b298c68b89688b80350b034daf2f7785b67, 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 This should fix a segfault when compiling graphics/gdal. PR: 276104 MFC after: 1 month --- contrib/llvm-project/clang/lib/AST/ASTContext.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/clang/lib/AST/ASTContext.cpp b/contrib/llvm-project/clang/lib/AST/ASTContext.cpp index 5eb7aa366456..9a0ede201059 100644 --- a/contrib/llvm-project/clang/lib/AST/ASTContext.cpp +++ b/contrib/llvm-project/clang/lib/AST/ASTContext.cpp @@ -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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404062018.436KIbAO030010>