I read about pasta on your blog post and decide to play with it. I am not familiar with the internals of libclang or llvm, so this issue may be user error.
I successfully built pasta and was able to run the demo programs. When I tried the dump-ast example on a toy example it worked as expected. However, when I tried it against my real project, it hits an assert. In particular, when I run it against this project: https://github.com/XRPLF/rippled using the following command line:
./dump-ast /home/swd/apps/clang-latest/bin/clang++ -DBOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS -DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT -DBOOST_BEAST_ALLOW_DEPRECATED -DBOOST_CONTAINER_FWD_BAD_DEQUE -DBOOST_COROUTINES_NO_DEPRECATION_WARNING -DBOOST_FILESYSTEM_DEPRECATED -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=\\\"/usr/bin/addr2line\\\" -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_USE_BACKTRACE -DBOOST_STACKTRACE_USE_NOOP -DCARES_STATICLIB -DDATE_HEADER_ONLY -DDEBUG -DENABLE_TESTS -DGIT_COMMIT_HASH=\\\"ed9064ce3f6de6da6b63417e59f3100c8e6c4c6d\\\" -DHAS_UNCAUGHT_EXCEPTIONS=1 -DOPENSSL_NO_SSL2 -D_DEBUG -I/home/swd/projs/ripple/mine/src/ed25519-donna -I/home/swd/projs/ripple/mine/src/secp256k1/include -I/home/swd/projs/ripple/mine/src -isystem /home/swd/.conan/data/boost/1.82.0/_/_/package/f81afbcfa21cf6994cf0e45c1b11229c01c767a7/include -isystem /home/swd/.conan/data/openssl/1.1.1u/_/_/package/06b9cd1c4dccbb163a99056eda646b0e168548fc/include -isystem /home/swd/.conan/data/libarchive/3.6.2/_/_/package/d9fea6983af2a77bcbe3f0b088cea5aef9308bd7/include -isystem /home/swd/.conan/data/lz4/1.9.3/_/_/package/06b9cd1c4dccbb163a99056eda646b0e168548fc/include -isystem /home/swd/projs/ripple/mine/cur_build/proto_gen_grpc -isystem /home/swd/.conan/data/grpc/1.50.1/_/_/package/d156c58fd512defbc1155e665684d7875e800ba9/include -isystem /home/swd/.conan/data/abseil/20220623.0/_/_/package/e84b6d643e7f97d33bf72700134618fbae8bbbf6/include -isystem /home/swd/.conan/data/c-ares/1.19.0/_/_/package/ed86cef4487c6b9ce327a03d24ced8142000e8b9/include -isystem /home/swd/.conan/data/re2/20230301/_/_/package/e84b6d643e7f97d33bf72700134618fbae8bbbf6/include -isystem /home/swd/.conan/data/zlib/1.2.13/_/_/package/06b9cd1c4dccbb163a99056eda646b0e168548fc/include -isystem /home/swd/.conan/data/protobuf/3.21.9/_/_/package/681b3b1dffc7e4dc6f5551cdb6e1fe56bdda3e85/include -isystem /home/swd/projs/ripple/mine/cur_build/proto_gen -isystem /home/swd/projs/ripple/mine/cur_build/proto_gen/src/ripple/proto -isystem /home/swd/.conan/data/soci/4.0.3/_/_/package/dc82e3681e64ed36c447531c9e4883a5c616a774/include -isystem /home/swd/.conan/data/bzip2/1.0.8/_/_/package/5e357164f23f7c4e38ebe87433827878dbe1a74c/include -isystem /home/swd/.conan/data/libbacktrace/cci.20210118/_/_/package/06b9cd1c4dccbb163a99056eda646b0e168548fc/include -isystem /home/swd/.conan/data/sqlite3/3.42.0/_/_/package/ae0e146c4c82ac1e46c279d15c964c80fedbdf5f/include -isystem /home/swd/.conan/data/nudb/2.0.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /home/swd/.conan/data/date/3.0.1/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -m64 -stdlib=libstdc++ -Wall -Wdeprecated -Wextra -Wno-unused-parameter -g -std=c++20 -fPIE -frtti -Wnon-virtual-dtor -Wno-sign-compare -Wno-char-subscripts -Wno-format -Wno-unused-local-typedefs -fstack-protector -o CMakeFiles/rippled.dir/src/ripple/app/ledger/impl/LedgerReplay.cpp.o -c /home/swd/projs/ripple/mine/src/ripple/app/ledger/impl/LedgerReplay.cpp
It hits the following assert:
dump-ast: /home/swd/projs/common/cxx-common-debug/vcpkg/buildtrees/llvm-16/src/org-16.0.5-90a3d25b70.clean/clang/lib/Sema/SemaType.cpp:8299: void HandleUnkownTypeAttrAsAnnotateTypeAttr({anonymous}::TypeProcessingState&, clang::QualType&, const clang::ParsedAttr&): Assertion `!PA.isArgIdent(Idx)' failed.
[1] 313418 IOT instruction (core dumped) ./dump-ast /home/swd/apps/clang-latest/bin/clang++ -DCARES_STATICLI
I attempted to debug this. I built the debug version of the libraries and went into gdb and attempted to try to find the offending code so I could create a minimal repro, but unfortunately my unfamiliarity with llvm is an obstacle. Two things we may be able to use as staring points.
In SemaType.cpp:8299
p Str
$8 = {
Data = 0x5555a3a89598 "__access__",
Length = 10
}
So the offending attribute is called "access".
In ParseDeclCXX.cpp:2107
p PP.getSourceManager().getPresumedLoc(StartLoc,true)
$6 = {
Filename = 0x5555a18575d0 "<pasta-input>",
ID = {
ID = 851074
},
Line = 1716508,
Col = 1,
IncludeLoc = {
ID = 0
}
}
What I'm trying to do here is find the name of the file that contains the offending code. Some searching pointed me to getPresumedLoc, but clearly <pasta-input> isn't useful to find the offending code. Perhaps you have a suggestion to find the code?
Also, I should mention I was only playing with pasta. Pasta obviously works and it's very possible I'm "holding it wrong". I'm not expecting help here, but thought I'd report the issue in case it was a possible bug in pasta (and will help trying to debug it after regular work hours if it's helpful to you).
I read about pasta on your blog post and decide to play with it. I am not familiar with the internals of libclang or llvm, so this issue may be user error.
I successfully built pasta and was able to run the demo programs. When I tried the
dump-astexample on a toy example it worked as expected. However, when I tried it against my real project, it hits an assert. In particular, when I run it against this project: https://github.com/XRPLF/rippled using the following command line:It hits the following assert:
I attempted to debug this. I built the debug version of the libraries and went into gdb and attempted to try to find the offending code so I could create a minimal repro, but unfortunately my unfamiliarity with llvm is an obstacle. Two things we may be able to use as staring points.
In SemaType.cpp:8299
So the offending attribute is called "access".
In ParseDeclCXX.cpp:2107
What I'm trying to do here is find the name of the file that contains the offending code. Some searching pointed me to
getPresumedLoc, but clearly<pasta-input>isn't useful to find the offending code. Perhaps you have a suggestion to find the code?Also, I should mention I was only playing with pasta. Pasta obviously works and it's very possible I'm "holding it wrong". I'm not expecting help here, but thought I'd report the issue in case it was a possible bug in pasta (and will help trying to debug it after regular work hours if it's helpful to you).