Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred while performing AST parsing on the line string fileName = picturePath;. #117979

Closed
ljtodo opened this issue Nov 28, 2024 · 1 comment
Labels
ClangIR Anything related to the ClangIR project crash Prefer [crash-on-valid] or [crash-on-invalid] duplicate Resolved as duplicate

Comments

@ljtodo
Copy link

ljtodo commented Nov 28, 2024

Maybe the implicit construct semantics of C++ are not supported, and ClangIR may not properly parse implicitly called constructors, causing problems in handling default parameters or lvalue operations called by implicit constructors.
https://godbolt.org/

C++ source:

#include <iostream> 
#include <fstream> 
#include <cstring> 
#include <map> 
#include <math.h> 
using namespace std;

size_t pictureDataSize = 0; 
void *pictureHostData; 
void *pictureDeviceData;

void ReadPictureTotHost(const char *picturePath) 
{
  string fileName = picturePath; 
  ifstream binFile(fileName, ifstream::binary); 
  binFile.seekg(0, binFile.end); 
  pictureDataSize = binFile.tellg(); 
  binFile.seekg(0, binFile.beg); 
  binFile.read((char*)pictureHostData, pictureDataSize); 
  binFile.close();
}

the output:

clang version 20.0.0git (https://github.com/llvm/clangir.git b414f2b7d8b8b97b626d5b0b2bf448a3f61d39ff)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-clangir-trunk-20241108/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
 (in-process)
 "/opt/compiler-explorer/clang-clangir-trunk-20241108/bin/clang-20" -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -v -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-clangir-trunk-20241108/lib/clang/20 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /opt/compiler-explorer/clang-clangir-trunk-20241108/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -fclangir -emit-cir -mllvm --x86-asm-syntax=intel -mmlir --mlir-print-ir-before-all -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x c++ <source>
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11
 /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11
 /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward
 /opt/compiler-explorer/clang-clangir-trunk-20241108/lib/clang/20/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
loc("<source>":14:21): error: l-value not implemented for 'CXXDefaultArgExpr'
clang++: /root/llvm-project/clang/lib/CIR/CodeGen/CIRGenExpr.cpp:2548: cir::LValue cir::CIRGenFunction::buildLValue(const clang::Expr*): Assertion `0 && "not implemented"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-clangir-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S -Xclang -fclangir -fcolor-diagnostics -fno-crash-diagnostics -Xclang -emit-cir -v -mmlir --mlir-print-ir-before-all <source>
1.	<eof> parser at end of file
2.	<source>:12:6: LLVM IR generation of declaration 'ReadPictureTotHost'
 #0 0x0000000002bd8cf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2bd8cf8)
 #1 0x0000000002bd69fc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2bd69fc)
 #2 0x0000000002b2c508 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000077bb98442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000077bb984969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000077bb98442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000077bb984287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000077bb9842871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000077bb98439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000042ac60d cir::CIRGenFunction::buildLValue(clang::Expr const*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42ac60d)
#10 0x00000000042ae33b cir::CIRGenFunction::buildReferenceBindingToExpr(clang::Expr const*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42ae33b)
#11 0x00000000042797ed cir::CIRGenFunction::buildCallArg(cir::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42797ed)
#12 0x0000000004279f26 cir::CIRGenFunction::buildCallArgs(cir::CallArgList&, cir::CIRGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const>>, cir::CIRGenFunction::AbstractCallee, unsigned int, cir::CIRGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4279f26)
#13 0x0000000004365b2f cir::CIRGenFunction::buildCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, cir::AggValueSlot, clang::CXXConstructExpr const*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4365b2f)
#14 0x00000000042e1cee cir::CIRGenFunction::buildCXXConstructExpr(clang::CXXConstructExpr const*, cir::AggValueSlot) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42e1cee)
#15 0x00000000042ce59e (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr const*) CIRGenExprAgg.cpp:0:0
#16 0x00000000042d7688 (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) CIRGenExprAgg.cpp:0:0
#17 0x00000000042dabb8 (anonymous namespace)::AggExprEmitter::VisitExprWithCleanups(clang::ExprWithCleanups*) CIRGenExprAgg.cpp:0:0
#18 0x00000000042d3774 cir::CIRGenFunction::buildAggExpr(clang::Expr const*, cir::AggValueSlot) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42d3774)
#19 0x0000000004289afe cir::CIRGenFunction::buildExprAsInit(clang::Expr const*, clang::ValueDecl const*, cir::LValue, bool) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4289afe)
#20 0x000000000428df79 cir::CIRGenFunction::buildAutoVarInit(cir::CIRGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x428df79)
#21 0x00000000042940af cir::CIRGenFunction::buildVarDecl(clang::VarDecl const&) (.part.0) CIRGenDecl.cpp:0:0
#22 0x000000000429457e cir::CIRGenFunction::buildDecl(clang::Decl const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x429457e)
#23 0x000000000431ccbf cir::CIRGenFunction::buildDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x431ccbf)
#24 0x0000000004322edf cir::CIRGenFunction::buildStmt(clang::Stmt const*, bool, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4322edf)
#25 0x00000000043257f7 cir::CIRGenFunction::buildCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, cir::AggValueSlot) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x43257f7)
#26 0x00000000042ff9c0 cir::CIRGenFunction::buildFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42ff9c0)
#27 0x000000000430b7a5 cir::CIRGenFunction::generateCode(clang::GlobalDecl, mlir::cir::FuncOp, cir::CIRGenFunctionInfo const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x430b7a5)
#28 0x0000000004252652 cir::CIRGenModule::buildGlobalFunctionDefinition(clang::GlobalDecl, mlir::Operation*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4252652)
#29 0x0000000004253d27 cir::CIRGenModule::buildGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4253d27)
#30 0x0000000004254346 cir::CIRGenModule::buildTopLevelDecl(clang::Decl*) (.part.0) CIRGenModule.cpp:0:0
#31 0x00000000042385d9 cir::CIRGenerator::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x42385d9)
#32 0x000000000411caaf cir::CIRGenConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x411caaf)
#33 0x000000000658b184 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x658b184)
#34 0x000000000411ed48 cir::CIRGenAction::ExecuteAction() (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x411ed48)
#35 0x00000000037f9819 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x37f9819)
#36 0x00000000037765be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x37765be)
#37 0x00000000038df9bc clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x38df9bc)
#38 0x0000000001090e1f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x1090e1f)
#39 0x0000000001088cfa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#40 0x000000000357f599 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#41 0x0000000002b2c9b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2b2c9b4)
#42 0x000000000357fb8f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#43 0x0000000003545d1d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x3545d1d)
#44 0x0000000003546e0d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x3546e0d)
#45 0x000000000354e2b5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x354e2b5)
#46 0x000000000108de39 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x108de39)
#47 0x0000000000fa17f4 main (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0xfa17f4)
#48 0x000077bb98429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#49 0x000077bb98429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#50 0x00000000010887ae _start (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x10887ae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
@tbaederr tbaederr added the ClangIR Anything related to the ClangIR project label Nov 28, 2024
@EugeneZelenko EugeneZelenko added crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Nov 28, 2024
@bcardosolopes
Copy link
Member

@ljtodo closing this given we already have llvm/clangir#1181

@EugeneZelenko EugeneZelenko closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2024
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ClangIR Anything related to the ClangIR project crash Prefer [crash-on-valid] or [crash-on-invalid] duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

4 participants