User Details
- User Since
- May 23 2018, 7:08 AM (252 w, 6 d)
Yesterday
Thu, Mar 23
Wed, Mar 15
Added a simple test and another test.
Instead of calling getTypeDeclType only the reuse of existing type is done
(this was the part that fixes the problem). In this way the underlying type
is still imported. The result is not correct but fixes some crash.
Tue, Mar 14
The problem is somewhat bigger and not fast to fix. This test shows what is problematic:
TEST_P(ASTImporterOptionSpecificTestBase, ImportExistingTypedefToUnnamedRecordPtr) { const char *Code = R"( typedef const struct { int fff; } * const T; extern T x; )"; Decl *ToTU = getToTuDecl(Code, Lang_C99); Decl *FromTU = getTuDecl(Code, Lang_C99);
There are some unresolved comments in the test (cast is not needed at Import and EXPECT_TRUE can be used) but otherwise LGTM.
(But I have a feeling that problems may happen with attributes like GuardedByAttr if these are imported before the field is added to the record. Probably it is better to only import the NoUniqueAddressAttr in VisitFieldDecl.)
Mon, Mar 13
My opinion is that we can not omit importing the "underlying type". The TypedefType has the type of the declaration (type of getDecl()) and the "underlying type" that may be different (this is the thing that comes from commit D133468). This is exactly different if TypedefType::typeMatchesDecl() (returns a stored value in TypedefDecl) returns true. In this case the type object is stored in the TypedefDecl node and is not the same as the type of declaration getDecl(). If function getTypeDeclType is used it creates the typedef type always with the type of getDecl() and the typeMatchesDecl will always return true for this type even if at the to-be-imported type it was false.
Fri, Mar 10
Change format of bug reports.
Now the problem is shown first, then the acceptable values.
Sometimes the messages can become too verbose (in case of
"should be NULL") or grammatically not totally correct,
I can not tell if this is acceptable but this was the most
simple implementation.
Thu, Mar 9
Tue, Mar 7
Mon, Mar 6
Fri, Mar 3
rebase, reformatted code
changed comments, small variable rename
The new test should be better, it imports the f function without new and no VaList should exist in the imported translation unit. It looks like the test.cpp is appended to the AST after the import of the other files. I changed function CreateVaListDecl to always use the AArch64 create function, the test did not fail.
Changed the lit test.
Thu, Mar 2
Wed, Mar 1
Updated the test.
A tried to find out how to add a correct test but could not check if this fails or not on AArch64 platform. The test should import the va_list declarations and then another variable std. I want to touch ASTContext only if a test failure is found on AArch64 that makes it necessary. In that case I would add a non-modifying function getVaListTagDeclIfExists, another option is to change all other simiar get functions to "getOrCreate" form to have consistent API.
Add a test.
Tue, Feb 28
Added a test case.
Mon, Feb 27
I think these patches are fix for separate problems and can be applied independently. It is not better if these are moved into one change. The other patch D144273 is not finished (it can get bigger), and a test for this change is needed. I try still to discover what the exact problem is here, then I can add an unit test.
Feb 24 2023
Probably we can add a new function ASTContext::getVaListTagDeclIfExists that does not create declarations if these do not exist. These new mentioned test cases would probably fail, but with a new non-modifying get function it can work.
Feb 23 2023
Feb 22 2023
Feb 17 2023
removed a not needed line
I have created the new patch D144273 that should fix the same AST import problems as this patch, without change of Sema.
The plan is to bring the checker out of the alpha package, the bug reports should be good enough for that. To modify bug report text generation a new patch would be better, after the current is finished. Maybe all single numbers in all allowed ranges that are 1, 2 (or 3?) long (like the 1,2,4,5,6 in the example) can be collected, this makes report generation more complicated than the current way.
Feb 16 2023
With this fix the std::__va_list is created at initialization of Sema, previously it was not there. Function CreateAArch64ABIBuiltinVaListDecl (ASTContext.cpp) makes the namespace std and __va_list record. This change fixes the problem with ASTImporter probably because the __va_list record exists before start of AST import, this way it is found and added to ASTImporterLookupTable at initialization (the original problem was caused because std::__va_list is missing from ASTImporterLookupTable). But I was thinking of other ways to fix the problem. My old fix for the problem may still work without any test failures:
It can happen (without any of the new fixes) that std::__va_list is created during the AST import process, it is created at first access. This can be the reason why it is missing from the lookup table: It is created implicitly by ASTContext code in the "to" context during import. To fix this problem, I think the above quoted code is a good solution: The va_list declaration is created at start of AST import (if it did not exist yet) (by the get function) and added to the lookup table. Probably it can be a problem that the va_list declaration and std namespace appears in a TU by just importing any code into it, but probably no tests will fail for this case. Another way to fix the problem is to add special handling of std::__va_list at least on the affected platforms to ASTImporterLookupTable but I did not check of this can be done. I do not like to change function ASTImporter::VisitTypedefType like in the very first fix of @vabridgers because it affects how every typedef is imported, and that can be incorrect. Probably some special handling of a record called __va_list at AST import can be a good fix too.
Feb 15 2023
But there should be a way to make the namespace "invisible" like it is done with std::bad_alloc, the linked commit seems to contain the code to "hide" the first std definition and this may not work any more. Another question is why this architecture has a probably not standard requirement. This may be a question for the discourse forum to reach the developers that can make a working fix.
make check available in all C++ versions, add compound operator related test and code
Feb 14 2023
Feb 13 2023
removed "IsLast"
small problem fix
Feb 10 2023
I changed the text descriptions to relational operators at some places, this is similar to how other clang analyzer messages look (for example notes at if statements), it is shorter, and probably more faster to understand ("<= 0" instead of "non-positive").
fixed another comment format problem
fixed another comment format problem
change of range descriptions, align comments
Feb 8 2023
Probably it is not always useful to explain why the argument is wrong. In cases when we can find out that the value is exactly between two consecutive valid ranges we can display a note, or when the exact value is known. Otherwise it may end up in something like "the value should be between 1 and 4 or between 6 and 10, but it is less than 1 or exactly 5 or greater than 10". The "good" cases are (when more information is available): "the value is less than 1", "the value is 5", "the value is greater than 10". If two bad ranges are known it may be OK too: "the value is less than 1 or it is exactly 5". The explanation may be possible to implement by test assumes for the negated ranges.
Feb 7 2023
Feb 6 2023
Replaced "of function" with "to" in checker messages.
Feb 3 2023
I looked at some of the failing tests but can not decide how to fix the problems. The problem seems to be with the extra namespace std that was not there before. I do not know what the tests are exactly testing. A part of the tests can be fixed by adding new expect lines but these must be platform specific.
I had the plan to add a note that tells the value that is out of range. In the most simple case it can work if we have a fixed value. But this may be the most obvious from the code too. Otherwise a new function can be added that can print the assumed constraint ranges.
Feb 2 2023
Jan 30 2023
Jan 27 2023
I have a fix for the AArch64 problems in test ImportCorrectTemplatedDecl, dcl-58-cpp, and the "Declaration not emitted!" assertion. I can not find at which tests the error: reference to 'std' is ambiguous appears. Probably the AArch64 (and Arm) tests could be run again with the current fixes applied.
I am not an expert in the frontend or ASTContext area, but I think that if a builtin declaration is created (ASTContext::getBuiltinVaListDecl) the identifier name for it should not be loaded from an external source (in function IdentifierTable::get). This load of identifier causes it to be get from ASTReader which in turn gets va_list it again from ASTContext because this is a predefined declaration. In this way 2 instances of va_list are added to the AST. The following call chain shows the problem (first create of va_list happens when Sema is initialized, second create happens when the __va_list is loaded by ASTReader as result of the first attempt to create it):
#0 clang::RecordDecl::RecordDecl (this=0x7fffd407a1c8, DK=clang::Decl::Record, TK=clang::TTK_Struct, C=..., DC=0x7fffd4041ec0, StartLoc=..., IdLoc=..., Id=0x7fffd407abb8, PrevDecl=0x0) at /local/clang/llvm2/llvm-project/clang/lib/AST/Decl.cpp:4700 #1 0x00007ffff4f26568 in clang::RecordDecl::Create (C=..., TK=clang::TTK_Struct, DC=0x7fffd4041ec0, StartLoc=..., IdLoc=..., Id=0x7fffd407abb8, PrevDecl=0x0) at /local/clang/llvm2/llvm-project/clang/lib/AST/Decl.cpp:4720 #2 0x00007ffff4ac92f6 in clang::ASTContext::buildImplicitRecord (this=0x7fffd402b110, Name=..., TK=clang::TTK_Struct) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:1216 #3 0x00007ffff4b0a8e3 in CreateAArch64ABIBuiltinVaListDecl (Context=0x7fffd402b110) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:8757 #4 0x00007ffff4af4be6 in CreateVaListDecl (Context=0x7fffd402b110, Kind=clang::TargetInfo::AArch64ABIBuiltinVaList) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9097 #5 0x00007ffff4af4b14 in clang::ASTContext::getBuiltinVaListDecl (this=0x7fffd402b110) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9117 #6 0x00007ffff4af4cab in clang::ASTContext::getVaListTagDecl (this=0x7fffd402b110) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9128 #7 0x00007ffff58b4461 in getPredefinedDecl (Context=..., ID=clang::serialization::PREDEF_DECL_VA_LIST_TAG) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:7496 #8 0x00007ffff58a38e5 in clang::ASTReader::GetExistingDecl (this=0x7fffd40436e0, ID=10) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:7525 #9 0x00007ffff58acabd in clang::ASTReader::GetDecl (this=0x7fffd40436e0, ID=10) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:7549 #10 0x00007ffff5887f51 in clang::ASTReader::SetGloballyVisibleDecls (this=0x7fffd40436e0, II=0x7fffd407abb8, DeclIDs=..., Decls=0x7fffd4079198) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:8596 #11 0x00007ffff58bafb5 in clang::ASTReader::finishPendingActions (this=0x7fffd40436e0) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:9276 #12 0x00007ffff58be073 in clang::ASTReader::FinishedDeserializing (this=0x7fffd40436e0) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:9783 #13 0x00007ffff58d093f in clang::ExternalASTSource::Deserializing::~Deserializing (this=0x7fffe2c990b0) at /local/clang/llvm2/llvm-project/clang/include/clang/AST/ExternalASTSource.h:86 #14 0x00007ffff58b7427 in clang::ASTReader::get (this=0x7fffd40436e0, Name=...) at /local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:8126 #15 0x00007ffff4b18c4b in clang::IdentifierTable::get (this=0x7fffd401b720, Name=...) at /local/clang/llvm2/llvm-project/clang/include/clang/Basic/IdentifierTable.h:605 #16 0x00007ffff4ac92bd in clang::ASTContext::buildImplicitRecord (this=0x7fffd402b110, Name=..., TK=clang::TTK_Struct) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:1217 #17 0x00007ffff4b0a8e3 in CreateAArch64ABIBuiltinVaListDecl (Context=0x7fffd402b110) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:8757 #18 0x00007ffff4af4be6 in CreateVaListDecl (Context=0x7fffd402b110, Kind=clang::TargetInfo::AArch64ABIBuiltinVaList) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9097 #19 0x00007ffff4af4b14 in clang::ASTContext::getBuiltinVaListDecl (this=0x7fffd402b110) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9117 #20 0x00007ffff4af4cab in clang::ASTContext::getVaListTagDecl (this=0x7fffd402b110) at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9128 #21 0x00007fffee43a586 in clang::Sema::Initialize (this=0x7fffd406a7e0) at /local/clang/llvm2/llvm-project/clang/lib/Sema/Sema.cpp:453 #22 0x00007fffe773b432 in clang::Parser::Initialize (this=0x7fffd40753c0) at /local/clang/llvm2/llvm-project/clang/lib/Parse/Parser.cpp:562 #23 0x00007fffe75d3fd4 in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=false) at /local/clang/llvm2/llvm-project/clang/lib/Parse/ParseAST.cpp:155 #24 0x00007ffff6169622 in clang::ASTFrontendAction::ExecuteAction (this=0x7fffd4014c70) at /local/clang/llvm2/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1162 #25 0x00007ffff6168fe8 in clang::FrontendAction::Execute (this=0x7fffd4014c70) at /local/clang/llvm2/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1055 #26 0x00007ffff60093fc in clang::ASTUnit::Parse (this=0x7fffd40118a0, PCHContainerOps=std::shared_ptr<clang::PCHContainerOperations> (empty) = {...}, OverrideMainBuffer=std::unique_ptr<llvm::MemoryBuffer> = {...}, VFS=...) at /local/clang/llvm2/llvm-project/clang/lib/Frontend/ASTUnit.cpp:1237 #27 0x00007ffff600cf5f in clang::ASTUnit::LoadFromCompilerInvocation (this=0x7fffd40118a0, PCHContainerOps=std::shared_ptr<clang::PCHContainerOperations> (empty) = {...}, PrecompilePreambleAfterNParses=2, VFS=...) at /local/clang/llvm2/llvm-project/clang/lib/Frontend/ASTUnit.cpp:1696 #28 0x00007ffff600dfc0 in clang::ASTUnit::LoadFromCommandLine (ArgBegin=0x7fffd4003440, ArgEnd=0x7fffd40034c0, PCHContainerOps=std::shared_ptr<clang::PCHContainerOperations> (empty) = {...}, Diags=..., ResourceFilesPath=..., OnlyLocalDecls=true, CaptureDiagnostics=clang::CaptureDiagsKind::All, RemappedFiles=..., RemappedFilesKeepOriginalName=true, PrecompilePreambleAfterNParses=2, TUKind=clang::TU_Complete, CacheCodeCompletionResults=false, IncludeBriefCommentsInCodeCompletion=false, AllowPCHWithCompilerErrors=true, SkipFunctionBodies=clang::SkipFunctionBodiesScope::None, SingleFileParse=false, UserFilesAreVolatile=true, ForSerialization=false, RetainExcludedConditionalBlocks=false, ModuleFormat=std::optional<llvm::StringRef> = {...}, ErrAST=0x7fffe2c9ba20, VFS=...) at /local/clang/llvm2/llvm-project/clang/lib/Frontend/ASTUnit.cpp:1820 #29 0x00007ffff79ed60c in clang_parseTranslationUnit_Impl (CIdx=0x7fffdc0151f0, source_filename=0x7fffffffe797 "-error-on-deserialized-decl=TopVar", command_line_args=0x7fffdc015520, num_command_line_args=11, unsaved_files=..., options=5, out_TU=0x7fffe349cc38) at /local/clang/llvm2/llvm-project/clang/tools/libclang/CIndex.cpp:3890 #30 0x00007ffff79ecbef in clang_parseTranslationUnit2FullArgv::$_1::operator() (this=0x7fffe349c9b8) at /local/clang/llvm2/llvm-project/clang/tools/libclang/CIndex.cpp:3973 #31 0x00007ffff79ecb45 in llvm::function_ref<void ()>::callback_fn<clang_parseTranslationUnit2FullArgv::$_1>(long) (callable=140737006651832) at /local/clang/llvm2/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45 #32 0x00007ffff359b119 in llvm::function_ref<void ()>::operator()() const (this=0x7fffe2c9bcf8) at /local/clang/llvm2/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68 #33 0x00007ffff35af7c4 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (this=0x7fffe349c9a0, Fn=...) at /local/clang/llvm2/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426 #34 0x00007ffff35afbcf in RunSafelyOnThread_Dispatch (UserData=0x7fffe349c8a0) at /local/clang/llvm2/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:507 #35 0x00007ffff35b0469 in _ZZN4llvm6thread18GenericThreadProxyISt5tupleIJPFvPvEPN12_GLOBAL__N_121RunSafelyOnThreadInfoEEEEEvS3_ENKUlOT_DpOT0_E_clIRS5_JRS8_EEEDaSB_SE_ (this=0x7fffe2c9be78, F=@0x7fffdc015588: 0x7ffff35afb80 <RunSafelyOnThread_Dispatch(void*)>, Args=@0x7fffdc015580: 0x7fffe349c8a0) at /local/clang/llvm2/llvm-project/llvm/include/llvm/Support/thread.h:43 #36 0x00007ffff35b0417 in _ZSt13__invoke_implIvZN4llvm6thread18GenericThreadProxyISt5tupleIJPFvPvEPN12_GLOBAL__N_121RunSafelyOnThreadInfoEEEEEvS4_EUlOT_DpOT0_E_JRS6_RS9_EESB_St14__invoke_otherOT0_DpOT1_ (__f=..., __args=@0x7fffdc015580: 0x7fffe349c8a0, __args=@0x7fffdc015580: 0x7fffe349c8a0) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/invoke.h:60 #37 0x00007ffff35b0387 in _ZSt8__invokeIZN4llvm6thread18GenericThreadProxyISt5tupleIJPFvPvEPN12_GLOBAL__N_121RunSafelyOnThreadInfoEEEEEvS4_EUlOT_DpOT0_E_JRS6_RS9_EENSt15__invoke_resultISB_JDpSD_EE4typeESC_SF_ (__fn=..., __args=@0x7fffdc015580: 0x7fffe349c8a0, __args=@0x7fffdc015580: 0x7fffe349c8a0) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/invoke.h:95 #38 0x00007ffff35b0313 in _ZSt12__apply_implIZN4llvm6thread18GenericThreadProxyISt5tupleIJPFvPvEPN12_GLOBAL__N_121RunSafelyOnThreadInfoEEEEEvS4_EUlOT_DpOT0_E_RSA_JLm0ELm1EEEDcSC_OT0_St16integer_sequenceImJXspT1_EEE (__f=..., __t=std::tuple containing = {...}) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/tuple:1662 #39 0x00007ffff35b0292 in _ZSt5applyIZN4llvm6thread18GenericThreadProxyISt5tupleIJPFvPvEPN12_GLOBAL__N_121RunSafelyOnThreadInfoEEEEEvS4_EUlOT_DpOT0_E_RSA_EDcSC_OT0_ (__f=..., __t=std::tuple containing = {...}) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/tuple:1671 #40 0x00007ffff35b0251 in llvm::thread::GenericThreadProxy<std::tuple<void (*)(void*), (anonymous namespace)::RunSafelyOnThreadInfo*> > (Ptr=0x7fffdc015580) at /local/clang/llvm2/llvm-project/llvm/include/llvm/Support/thread.h:41 #41 0x00007ffff35afee5 in llvm::thread::ThreadProxy<std::tuple<void (*)(void*), (anonymous namespace)::RunSafelyOnThreadInfo*> > (Ptr=0x7fffdc015580) at /local/clang/llvm2/llvm-project/llvm/include/llvm/Support/thread.h:55 #42 0x00007ffff7bbb6db in start_thread (arg=0x7fffe2c9c700) at pthread_create.c:463 #43 0x00007ffff26e261f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Jan 26 2023
The "Declaration not emitted" crash is reproducible by change of file "test/Index/targeted-cursor.c", the similar lines should be replaced to this (only the target aarch64 is added):
// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \ // RUN: c-index-test -cursor-at=%s:5:10 %s -target aarch64 -include %t.h \ // RUN: -Xclang -error-on-deserialized-decl=PreambleVar \ // RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \ // RUN: -Xclang -error-on-deserialized-decl=TopVar \ // RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
The other "run" lines in the file can be removed to simplify the test. The run lines that are above these lines are not producing crash.
In my previous comments I indicated how to fix the problem in the lang-tidy check, and I could reproduce the crash in ImportCorrectTemplatedDecl and have the fix for it. I can reproduce the assertion "Declaration not emitted!" but did not found the fix, the AST contains 2 unlinked instances of struct va_list definition in this case for unknown reason (I think there should be one of these declarations).
At least a part of the failures is reproducible with -target aarch64 option. I try to fix the failures.
The test causes this assert if the fix is not applied:
Unhandled type of friend class UNREACHABLE executed at /local/clang/llvm2/llvm-project/clang/lib/AST/ASTImporterLookupTable.cpp:71! #0 0x00007f4380b90e0a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /local/clang/llvm2/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11 #1 0x00007f4380b90fdb PrintStackTraceSignalHandler(void*) /local/clang/llvm2/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1 #2 0x00007f4380b8f58b llvm::sys::RunSignalHandlers() /local/clang/llvm2/llvm-project/llvm/lib/Support/Signals.cpp:103:5 #3 0x00007f4380b91751 SignalHandler(int) /local/clang/llvm2/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1 #4 0x00007f43840b1980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980) #5 0x00007f437fa40e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0 #6 0x00007f437fa427f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0 #7 0x00007f4380a132c4 /local/clang/llvm2/llvm-project/llvm/lib/Support/ErrorHandling.cpp:212:3 #8 0x00007f438265cc05 clang::(anonymous namespace)::Builder::VisitFriendDecl(clang::FriendDecl*) /local/clang/llvm2/llvm-project/clang/lib/AST/ASTImporterLookupTable.cpp:0:11 #9 0x00007f438265ca40 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::WalkUpFromFriendDecl(clang::FriendDecl*) /local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:71:1 #10 0x00007f43825e2505 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseFriendDecl(clang::FriendDecl*) /local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1550:1 #11 0x00007f43825dfa49 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseDecl(clang::Decl*) /local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:71:1 #12 0x00007f4382648488 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseDeclContextHelper(clang::DeclContext*) /local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1489:7 #13 0x00007f43825e7038 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseCXXRecordDecl(clang::CXXRecordDecl*) /local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2015:1 #14 0x00007f43825dff7f clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseDecl(clang::Decl*) /local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:295:1 #15 0x00007f4382648488 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseDeclContextHelper(clang::DeclContext*) /local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1489:7 #16 0x00007f43825ee041 clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) /local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1599:1 #17 0x00007f43825e084d clang::RecursiveASTVisitor<clang::(anonymous namespace)::Builder>::TraverseDecl(clang::Decl*) /local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:645:1 #18 0x00007f43825df7d4 clang::ASTImporterLookupTable::ASTImporterLookupTable(clang::TranslationUnitDecl&) /local/clang/llvm2/llvm-project/clang/lib/AST/ASTImporterLookupTable.cpp:88:1 #19 0x0000000000655a44 std::_MakeUniq<clang::ASTImporterLookupTable>::__single_object std::make_unique<clang::ASTImporterLookupTable, clang::TranslationUnitDecl&>(clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/unique_ptr.h:821:34 #20 0x0000000000655933 clang::ASTImporterSharedState::ASTImporterSharedState(clang::TranslationUnitDecl&) /local/clang/llvm2/llvm-project/clang/include/clang/AST/ASTImporterSharedState.h:52:19 #21 0x00000000006558d1 void __gnu_cxx::new_allocator<clang::ASTImporterSharedState>::construct<clang::ASTImporterSharedState, clang::TranslationUnitDecl&>(clang::ASTImporterSharedState*, clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:136:60 #22 0x00000000006555ed void std::allocator_traits<std::allocator<clang::ASTImporterSharedState>>::construct<clang::ASTImporterSharedState, clang::TranslationUnitDecl&>(std::allocator<clang::ASTImporterSharedState>&, clang::ASTImporterSharedState*, clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/alloc_traits.h:475:56 #23 0x000000000065544b std::__shared_ptr<clang::ASTImporterSharedState, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<clang::ASTImporterSharedState>, clang::TranslationUnitDecl&>(std::_Sp_make_shared_tag, std::allocator<clang::ASTImporterSharedState> const&, clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr_base.h:1327:4 #24 0x00000000006553ad std::shared_ptr<clang::ASTImporterSharedState>::shared_ptr<std::allocator<clang::ASTImporterSharedState>, clang::TranslationUnitDecl&>(std::_Sp_make_shared_tag, std::allocator<clang::ASTImporterSharedState> const&, clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr.h:345:4 #25 0x0000000000655316 std::shared_ptr<clang::ASTImporterSharedState> std::allocate_shared<clang::ASTImporterSharedState, std::allocator<clang::ASTImporterSharedState>, clang::TranslationUnitDecl&>(std::allocator<clang::ASTImporterSharedState> const&, clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr.h:690:14 #26 0x000000000064e6f3 std::shared_ptr<clang::ASTImporterSharedState> std::make_shared<clang::ASTImporterSharedState, clang::TranslationUnitDecl&>(clang::TranslationUnitDecl&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr.h:706:7 #27 0x000000000064bd3e clang::ast_matchers::ASTImporterTestBase::lazyInitSharedState(clang::TranslationUnitDecl*) /local/clang/llvm2/llvm-project/clang/unittests/AST/ASTImporterFixtures.cpp:113:22 #28 0x000000000064bf9f clang::ast_matchers::ASTImporterTestBase::lazyInitToAST(clang::TestLanguage, llvm::StringRef, llvm::StringRef) /local/clang/llvm2/llvm-project/clang/unittests/AST/ASTImporterFixtures.cpp:128:1 #29 0x000000000064c77e clang::ast_matchers::ASTImporterTestBase::getToTuDecl(llvm::StringRef, clang::TestLanguage) /local/clang/llvm2/llvm-project/clang/unittests/AST/ASTImporterFixtures.cpp:191:3 #30 0x00000000006a5a13 clang::ast_matchers::ASTImporterLookupTableTest_LookupFindsFriendClassDeclWithUsingTypeDoesNotAssert_Test::TestBody() /local/clang/llvm2/llvm-project/clang/unittests/AST/ASTImporterTest.cpp:5165:24 #31 0x00007f4380c959c4 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2433:3 #32 0x00007f4380c7b132 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2488:5 #33 0x00007f4380c63173 testing::Test::Run() /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2515:3 #34 0x00007f4380c63a4d testing::TestInfo::Run() /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:12 #35 0x00007f4380c6401c testing::TestSuite::Run() /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2815:44 #36 0x00007f4380c6cde1 testing::internal::UnitTestImpl::RunAllTests() /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:5337:24 #37 0x00007f4380c991e4 bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2433:3 #38 0x00007f4380c7d472 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:2488:5 #39 0x00007f4380c6c9aa testing::UnitTest::Run() /local/clang/llvm2/llvm-project/third-party/unittest/googletest/src/gtest.cc:4925:10 #40 0x00007f43844c4d01 RUN_ALL_TESTS() /local/clang/llvm2/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2472:3 #41 0x00007f43844c4c40 main /local/clang/llvm2/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:3 #42 0x00007f437fa23c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0 #43 0x00000000005ee18a _start (./tools/clang/unittests/AST/ASTTests+0x5ee18a)
Jan 25 2023
New patch after more thorough debugging.
Jan 22 2023
I plan to improve the fix and change the code.
Jan 9 2023
Jan 6 2023
Jan 5 2023
Adding test for summary case, change of comment.
Jan 4 2023
Removed class NotZeroConstraint.
Jan 3 2023
I suppose the tests are done in the followup patch mostly?
Yes the tests in the next patch should cover the cases.
Removed old commment, updated a test run line.
Jan 2 2023
Dec 22 2022
This crash is produced if the test is run without the fix:
[ RUN ] ParameterizedTests/ASTImporterOptionSpecificTestBase.ImportInjectedClassNameType/0 ASTTests: llvm-project/clang/lib/AST/ASTContext.cpp:4678: clang::QualType clang::ASTContext::getTypedefType(const clang::TypedefNameDecl *, clang::QualType) const: Assertion `hasSameType(Decl->getUnderlyingType(), Underlying)' failed. #0 0x00007fd8cc15141a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11 #1 0x00007fd8cc1515eb PrintStackTraceSignalHandler(void*) llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1 #2 0x00007fd8cc14fb9b llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:103:5 #3 0x00007fd8cc151d61 SignalHandler(int) llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1 #4 0x00007fd8cf630980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980) #5 0x00007fd8cb018e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0 #6 0x00007fd8cb01a7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0 #7 0x00007fd8cb00a3fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0 #8 0x00007fd8cb00a472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472) #9 0x00007fd8cd95cf20 clang::ASTContext::getTypedefType(clang::TypedefNameDecl const*, clang::QualType) const llvm-project/clang/lib/AST/ASTContext.cpp:4680:26 #10 0x00007fd8cda9a574 clang::ASTNodeImporter::VisitTypedefType(clang::TypedefType const*) llvm-project/clang/lib/AST/ASTImporter.cpp:1365:34 #11 0x00007fd8cdb05191 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:75:1 #12 0x00007fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8 #13 0x00007fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8 #14 0x00007fd8cdadb809 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) llvm-project/clang/lib/AST/ASTImporter.cpp:219:23 #15 0x00007fd8cda9be49 clang::ASTNodeImporter::VisitElaboratedType(clang::ElaboratedType const*) llvm-project/clang/lib/AST/ASTImporter.cpp:1595:8 #16 0x00007fd8cdb04eb9 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:45:1 #17 0x00007fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8 #18 0x00007fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8 #19 0x00007fd8cdadb809 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) llvm-project/clang/lib/AST/ASTImporter.cpp:219:23 #20 0x00007fd8cda98d9b clang::ASTNodeImporter::VisitPointerType(clang::PointerType const*) llvm-project/clang/lib/AST/ASTImporter.cpp:1155:8 #21 0x00007fd8cdb0505d clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:62:1 #22 0x00007fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8 #23 0x00007fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8 #24 0x00007fd8cdadb809 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) llvm-project/clang/lib/AST/ASTImporter.cpp:219:23 #25 0x00007fd8cda99d11 clang::ASTNodeImporter::VisitFunctionProtoType(clang::FunctionProtoType const*) llvm-project/clang/lib/AST/ASTImporter.cpp:1299:10 #26 0x00007fd8cdb04ef1 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType>>::Visit(clang::Type const*) build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:48:1 #27 0x00007fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8 #28 0x00007fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8 #29 0x00007fd8cdadb809 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) llvm-project/clang/lib/AST/ASTImporter.cpp:219:23 #30 0x00007fd8cdaddb5b clang::QualType clang::ASTNodeImporter::importChecked<clang::QualType>(llvm::Error&, clang::QualType const&) llvm-project/clang/lib/AST/ASTImporter.cpp:698:12 #31 0x00007fd8cdaa8c38 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) llvm-project/clang/lib/AST/ASTImporter.cpp:3597:12 #32 0x00007fd8cdaaabae clang::ASTNodeImporter::VisitCXXMethodDecl(clang::CXXMethodDecl*) llvm-project/clang/lib/AST/ASTImporter.cpp:3810:10 #33 0x00007fd8cdb04361 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*>>::Visit(clang::Decl*) build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:443:1 #34 0x00007fd8cdad0a26 clang::ASTImporter::ImportImpl(clang::Decl*) llvm-project/clang/lib/AST/ASTImporter.cpp:8619:19 #35 0x00007fd8cdab3a72 clang::ASTImporter::Import(clang::Decl*) llvm-project/clang/lib/AST/ASTImporter.cpp:9008:8 #36 0x000000000064c702 clang::ast_matchers::ASTImporterTestBase::TU::import(std::shared_ptr<clang::ASTImporterSharedState> const&, clang::ASTUnit*, clang::Decl*) llvm-project/clang/unittests/AST/ASTImporterFixtures.cpp:83:12 #37 0x000000000064d4c2 clang::ast_matchers::ASTImporterTestBase::Import(clang::Decl*, clang::TestLanguage) llvm-project/clang/unittests/AST/ASTImporterFixtures.cpp:199:9 #38 0x00000000006da446 clang::FunctionDecl* clang::ast_matchers::ASTImporterTestBase::Import<clang::FunctionDecl>(clang::FunctionDecl*, clang::TestLanguage) llvm-project/clang/unittests/AST/ASTImporterFixtures.h:185:12 #39 0x00000000006c836d clang::ast_matchers::ASTImporterOptionSpecificTestBase_ImportInjectedClassNameType_Test::TestBody() llvm-project/clang/unittests/AST/ASTImporterTest.cpp:8102:15 #40 0x00007fd8cc2559c4 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) llvm-project/third-party/unittest/googletest/src/gtest.cc:2433:3 #41 0x00007fd8cc23b132 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) llvm-project/third-party/unittest/googletest/src/gtest.cc:2488:5 #42 0x00007fd8cc223173 testing::Test::Run() llvm-project/third-party/unittest/googletest/src/gtest.cc:2515:3 #43 0x00007fd8cc223a4d testing::TestInfo::Run() llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:12 #44 0x00007fd8cc22401c testing::TestSuite::Run() llvm-project/third-party/unittest/googletest/src/gtest.cc:2815:44 #45 0x00007fd8cc22cde1 testing::internal::UnitTestImpl::RunAllTests() llvm-project/third-party/unittest/googletest/src/gtest.cc:5337:24 #46 0x00007fd8cc2591e4 bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) llvm-project/third-party/unittest/googletest/src/gtest.cc:2433:3 #47 0x00007fd8cc23d472 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) llvm-project/third-party/unittest/googletest/src/gtest.cc:2488:5 #48 0x00007fd8cc22c9aa testing::UnitTest::Run() llvm-project/third-party/unittest/googletest/src/gtest.cc:4925:10 #49 0x00007fd8cfa43d01 RUN_ALL_TESTS() llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2472:3 #50 0x00007fd8cfa43c40 main llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:3 #51 0x00007fd8caffbc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0 #52 0x00000000005eeb1a _start (tools/clang/unittests/AST/ASTTests+0x5eeb1a)