https://bugs.llvm.org/show_bug.cgi?id=41478
Bug ID: 41478
Summary: clang::tooling::getUSRsForDeclaration segfault for
forward declaration
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: libclang
Assignee: unassignedclangb...@nondot.org
Reporter: winte...@in.tum.de
CC: kli...@google.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Created attachment 21766
--> https://bugs.llvm.org/attachment.cgi?id=21766&action=edit
The minimal example to reproduce
clang::tooling::getUSRsForDeclaration segfault when presented with a forward
declaration without a definition.
This is caused by repeated call to RecordDecl->getDefinition() in
AdditionalUSRFinder::handleCXXRecordDecl
https://clang.llvm.org/doxygen/USRFindingAction_8cpp_source.html#l00105
which returns a nullptr
followed by
AdditionalUSRFinder::addUSRsOfCtorDtors
https://clang.llvm.org/doxygen/USRFindingAction_8cpp_source.html#l00124
where it is this time called on the nullptr returned before, resulting in a
segfault
A simple fix would be checking for nullptr before the second call, as is done
directly afterwards, e.g. duplicating lines
https://clang.llvm.org/doxygen/USRFindingAction_8cpp_source.html#l00126
to
https://clang.llvm.org/doxygen/USRFindingAction_8cpp_source.html#l00128
directly before
https://clang.llvm.org/doxygen/USRFindingAction_8cpp_source.html#l00124
This segfault/assertion fail can be reproduced by running the example attached
(main.cpp) on the file test.cpp
Tested with clang/llvm version 8 but the code is unchanged for 9 as well.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs