Issue 86735
Summary `clang-18 -extract-api -x c++-header /home/matthew/attempt.h`
Labels new issue
Assignees
Reporter mattkae
    ## Problem
`clang` is crashing when trying to extract the API from a very simple C++ header file because of `#include`s.

## Program
```c++
#include <iostream>

class X
{
};

```

## Repro
1. Copy the program into a file somewhere
2. Run `clang-18 -extract-api -x c++-header /absolute/path/to/program.h`
3. Get the error

Note that removing the `#include <iostream>` line fixes the error.

## Version
```
$ clang-18 --version
Ubuntu clang version 18.1.3 (++20240322073153+ef6d1ec07c69-1~exp1~20240322193300.86)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

```

## Output
```
Stack dump:
0.      Program arguments: clang-18 -extract-api -x c++-header /home/matthew/attempt.h
1. <eof> parser at end of file
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.so.18.1 0x0000739654de9256 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM.so.18.1      0x0000739654de7210 llvm::sys::RunSignalHandlers() + 80
2  libLLVM.so.18.1 0x0000739654d38e70
3  libc.so.6            0x0000739650a42520
4 libclang-cpp.so.18.1 0x000073965b41713e clang::extractapi::APISet::addCXXField(clang::extractapi::APIRecord*, llvm::StringRef, llvm::StringRef, clang::PresumedLoc, clang::extractapi::AvailabilityInfo, std::vector<clang::RawComment::CommentLine, std::allocator<clang::RawComment::CommentLine>> const&, clang::extractapi::DeclarationFragments, clang::extractapi::DeclarationFragments, clang::extractapi::AccessControl, bool) + 350
5  libclang-cpp.so.18.1 0x000073965b46e8b6
6 libclang-cpp.so.18.1 0x000073965b444a03
7  libclang-cpp.so.18.1 0x000073965b43bdf3
8  libclang-cpp.so.18.1 0x000073965b44703b
9 libclang-cpp.so.18.1 0x000073965b43b9e3
10 libclang-cpp.so.18.1 0x000073965b43bfdb
11 libclang-cpp.so.18.1 0x000073965b43b88a
12 libclang-cpp.so.18.1 0x0000739659ded256 clang::ParseAST(clang::Sema&, bool, bool) + 614
13 libclang-cpp.so.18.1 0x000073965bc1def5 clang::FrontendAction::Execute() + 85
14 libclang-cpp.so.18.1 0x000073965bb974e4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 708
15 libclang-cpp.so.18.1 0x000073965bc986be clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 750
16 clang-18             0x00005b1114c15a25 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 4069
17 clang-18 0x00005b1114c12e25
18 libclang-cpp.so.18.1 0x000073965b84f999
19 libLLVM.so.18.1      0x0000739654d38c0c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 140
20 libclang-cpp.so.18.1 0x000073965b84f32e clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const + 366
21 libclang-cpp.so.18.1 0x000073965b8178c1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 897
22 libclang-cpp.so.18.1 0x000073965b817b0e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 142
23 libclang-cpp.so.18.1 0x000073965b8340ed clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 333
24 clang-18             0x00005b1114c12794 clang_main(int, char**, llvm::ToolContext const&) + 11172
25 clang-18 0x00005b1114c20286 main + 102
26 libc.so.6 0x0000739650a29d90
27 libc.so.6            0x0000739650a29e40 __libc_start_main + 128
28 clang-18             0x00005b1114c0f895 _start + 37
clang-18: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 18.1.3 (++20240322073153+ef6d1ec07c69-1~exp1~20240322193300.86)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-18: note: diagnostic msg: 
********************

```

## Files
[attempt-21509c.sh.txt](https://github.com/llvm/llvm-project/files/14764337/attempt-21509c.sh.txt)
[attempt-21509c.hh.txt](https://github.com/llvm/llvm-project/files/14764338/attempt-21509c.hh.txt)

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to