[llvm-bugs] [Bug 46131] New: libclang crash on lambda capture using deleted copy constructor
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 29 07:53:07 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46131
Bug ID: 46131
Summary: libclang crash on lambda capture using deleted copy
constructor
Product: clang
Version: 10.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: libclang
Assignee: unassignedclangbugs at nondot.org
Reporter: f.dennemont at gmail.com
CC: klimek at google.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Created attachment 23554
--> https://bugs.llvm.org/attachment.cgi?id=23554&action=edit
The file that crashes libclang.
== Overview
When using libclang to parse the attached C++ file, it crashes. The C++ file
simply contains a lambda definition that captures by copy an object that has a
deleted copy constructor.
== Steps to Reproduce
1. Download the attached file.
2. Use libclang to parse that file. I use a simple code similar to this for the
parsing :
//---
ClangIndex = createIndex(false, false);
unsigned int options =
CXTranslationUnit_DetailedPreprocessingRecord|CXTranslationUnit_KeepGoing;
char const* const flags = ["-w", "-O0", "--std=c++17", "-c",
"--target=i686-pc-win32", "-fexceptions", "-fno-rtti", "-undef",
"-ferror-limit=100000", "-xc++", "-fshort-wchar",
"-Wno-dollar-in-identifier-extension"];
TU = parseTranslationUnit(ClangIndex, BuildOptions.szFileName, flags,
sizeof(flags)/sizeof(*Flags), Ocp.UnsavedFiles, Ocp.UnsavedFileCount, options);
CXCursor startCursor = getTranslationUnitCursor(TU);
visitChildren(startCursor, buildTree, &Datas);
//---
== Actual Results
The application crashed.
== Expected Results
No crash and libclang gives a diagnostic with a message similar to "call to a
deleted copy constructor".
== Build Date & Hardware
2020-05-29 on Windows 7.
== libclang version : 10 (on that commit :
https://github.com/llvm/llvm-project/commit/92d5c1be9ee93850c0a8903f05f36a23ee835dc2)
== Additional Information
I fixed the bug locally by simply ignoring a null pointer, like this :
in clang/tools/libclang/CIndex.cpp line 3174 :
// Visit init captures
for (auto InitExpr : E->capture_inits()) {
- if (Visit(InitExpr))
+ if (InitExpr && Visit(InitExpr))
return true;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200529/ab500180/attachment.html>
More information about the llvm-bugs
mailing list