[all-commits] [llvm/llvm-project] b12a74: [Clang][AST] Fix a crash on attaching doc comments...
Shanzhi via All-commits
all-commits at lists.llvm.org
Thu Feb 8 15:59:49 PST 2024
Branch: refs/heads/release/18.x
Home: https://github.com/llvm/llvm-project
Commit: b12a742c20ae548c5d84f1719f9199577b382ccd
https://github.com/llvm/llvm-project/commit/b12a742c20ae548c5d84f1719f9199577b382ccd
Author: Shanzhi <chenshanzhi at huawei.com>
Date: 2024-02-08 (Thu, 08 Feb 2024)
Changed paths:
M clang/lib/AST/ASTContext.cpp
A clang/test/AST/ast-crash-doc-function-template.cpp
Log Message:
-----------
[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
(cherry picked from commit 5f4ee5a2dfa97fe32ee62d1d67aa1413d5a059e6)
More information about the All-commits
mailing list