[PATCH] D82740: [libclang]: check validity before visiting Stmt node
Milian Wolff via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 29 01:02:36 PDT 2020
milianw created this revision.
milianw added reviewers: bkramer, yvvan, nik.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
Fixes crash when visiting a partial AST after encountering
a parse error in the input code:
#5 clang::Stmt::getStmtClass (this=<optimized out>) at llvm-project/clang/include/clang/AST/Stmt.h:1125
#6 clang::cxcursor::MakeCXCursor (S=S at entry=0x0, Parent=0x0, TU=0x7f8c6c5186b0, RegionOfInterest=...) at llvm-project/clang/tools/libclang/CXCursor.cpp:132
#7 0x00007f8caddc96e5 in clang::cxcursor::CursorVisitor::EnqueueWorkList (this=this at entry=0x7f8c9bffc330, WL=..., S=S at entry=0x0) at llvm-project/clang/tools/libclang/CIndex.cpp:3028
#8 0x00007f8cadde4e2c in clang::cxcursor::CursorVisitor::Visit (this=this at entry=0x7f8c9bffc330, S=0x0) at llvm-project/clang/tools/libclang/CIndex.cpp:3256
#9 0x00007f8cadde4604 in clang::cxcursor::CursorVisitor::RunVisitorWorkList (this=this at entry=0x7f8c9bffc330, WL=...) at llvm-project/clang/tools/libclang/CIndex.cpp:3214
#10 0x00007f8cadde4e37 in clang::cxcursor::CursorVisitor::Visit (this=this at entry=0x7f8c9bffc330, S=0x7f8c6c17dc30) at llvm-project/clang/tools/libclang/CIndex.cpp:3257
#11 0x00007f8cadddeccb in clang::cxcursor::CursorVisitor::VisitChildren (this=this at entry=0x7f8c9bffc330, Cursor=...) at llvm-project/clang/tools/libclang/CIndex.cpp:515
#12 0x00007f8cadde688f in clang_visitChildren (parent=..., visitor=0x7f8caef6ddda <(anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData)>, client_data=0x7f8c9bffe3b0) at llvm-project/clang/tools/libclang/CIndex.cpp:4450
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82740
Files:
clang/tools/libclang/CIndex.cpp
Index: clang/tools/libclang/CIndex.cpp
===================================================================
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3243,6 +3243,8 @@
}
bool CursorVisitor::Visit(const Stmt *S) {
+ if (!S)
+ return false;
VisitorWorkList *WL = nullptr;
if (!WorkListFreeList.empty()) {
WL = WorkListFreeList.back();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82740.274003.patch
Type: text/x-patch
Size: 385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200629/7f95e2ad/attachment-0001.bin>
More information about the cfe-commits
mailing list