| Issue |
203751
|
| Summary |
[clang][ObjC] Assertion `D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"' failed.` on completion
|
| Labels |
|
| Assignees |
|
| Reporter |
hongtaihu
|
This input is generated by a fuzzer.
https://godbolt.org/z/MejWPsbz1
```objective-c++
@interface SuperClass
@end
@interface A : SuperClass {
struct {
unsigned char a : 1;
unsigned char b : 1;
unsigned char c : 1;
} _flags;
}
@end
@implementation A
- (id)init {
_flags.a = 1;
_flags.b = 1;
_flags.c = 1;
}
@end
```
Seems to be introduced since clang 15.0.0
use
```
-x objective-c++ -fsyntax-only -Xclang -code-completion-at=example.cpp:7:5
```
stacktrace
```
clang++: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/DeclBase.cpp:1796: void clang::DeclContext::addHiddenDecl(clang::Decl*): Assertion `D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -x objective-c++ -fsyntax-only -Xclang -code-completion-at=example.cpp:7:5 <source>
1. <source>:7:5: current parser token ''
#0 0x000000000439b708 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x439b708)
#1 0x0000000004398544 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4398544)
#2 0x0000000004398b64 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4398b64)
#3 0x00000000042d5368 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007de699045330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007de69909eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x00007de69904527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007de6990288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007de69902881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007de69903b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000007e786f0 clang::DeclContext::addDecl(clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e786f0)
#11 0x0000000007008077 clang::Sema::PushOnScopeChains(clang::NamedDecl*, clang::Scope*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7008077)
#12 0x0000000007008808 InjectAnonymousStructOrUnionMembers(clang::Sema&, clang::Scope*, clang::DeclContext*, clang::RecordDecl*, clang::AccessSpecifier, clang::StorageClass, llvm::SmallVectorImpl<clang::NamedDecl*>&) SemaDecl.cpp:0:0
#13 0x0000000007036a00 clang::Sema::BuildAnonymousStructOrUnion(clang::Scope*, clang::DeclSpec&, clang::AccessSpecifier, clang::RecordDecl*, clang::PrintingPolicy const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7036a00)
#14 0x0000000007038681 clang::Sema::ParsedFreeStandingDeclSpec(clang::Scope*, clang::AccessSpecifier, clang::DeclSpec&, clang::ParsedAttributesView const&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool, clang::RecordDecl*&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7038681)
#15 0x000000000703a627 clang::Sema::ParsedFreeStandingDeclSpec(clang::Scope*, clang::AccessSpecifier, clang::DeclSpec&, clang::ParsedAttributesView const&, clang::RecordDecl*&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x703a627)
#16 0x0000000006cadb57 clang::Parser::ParseStructDeclaration(clang::ParsingDeclSpec&, llvm::function_ref<clang::Decl* (clang::ParsingFieldDeclarator&)>, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cadb57)
#17 0x0000000006d06a30 clang::Parser::ParseObjCClassInstanceVariables(clang::ObjCContainerDecl*, clang::tok::ObjCKeywordKind, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d06a30)
#18 0x0000000006d13023 clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d13023)
#19 0x0000000006d13b74 clang::Parser::ParseObjCAtDirectives(clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d13b74)
#20 0x0000000006c61d0d clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c61d0d)
#21 0x0000000006c62865 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c62865)
#22 0x0000000006c4374a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4374a)
#23 0x00000000051c1ac8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51c1ac8)
#24 0x000000000513eecd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x513eecd)
#25 0x00000000052c069d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52c069d)
#26 0x0000000000e21a7c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe21a7c)
#27 0x0000000000e1871a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#28 0x0000000000e1889d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#29 0x0000000004efda79 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
#30 0x00000000042d57a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42d57a4)
#31 0x0000000004efe0c6 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
#32 0x0000000004eba9f2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4eba9f2)
#33 0x0000000004ebb99e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ebb99e)
#34 0x0000000004ec31d5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ec31d5)
#35 0x0000000000e1dfb2 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe1dfb2)
#36 0x0000000000cc412a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc412a)
#37 0x00007de69902a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#38 0x00007de69902a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#39 0x0000000000e180c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe180c5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs