From 1f96ff26359370ad0949346239bb3ff5bf227867 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 17 Dec 2024 14:18:36 +0100 Subject: [PATCH 1/6] testclangimport.cpp: added missing location information in Clang AST excerpts --- test/testclangimport.cpp | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 7909eb923c5..17eb91e11de 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -281,7 +281,7 @@ class TestClangImport : public TestFixture { } void conditionalExpr() { - const char clang[] = "`-VarDecl 0x257cc88 col:5 x 'int' cinit\n" + const char clang[] = "`-VarDecl 0x257cc88 col:5 x 'int' cinit\n" " `-ConditionalOperator 0x257cda8 'int'\n" " |-ImplicitCastExpr 0x257cd60 'int' \n" " | `-DeclRefExpr 0x257cce8 'int' lvalue Var 0x257cae0 'a' 'int'\n" @@ -325,7 +325,7 @@ class TestClangImport : public TestFixture { } void cxxConstructorDecl1() { - const char clang[] = "|-CXXConstructorDecl 0x428e890 col:11 C 'void ()'\n" + const char clang[] = "|-CXXConstructorDecl 0x428e890 col:11 C 'void ()'\n" "| `-CompoundStmt 0x428ea58 \n" "| `-BinaryOperator 0x428ea30 'int' lvalue '='\n" "| |-MemberExpr 0x428e9d8 'int' lvalue ->x 0x428e958\n" @@ -336,13 +336,13 @@ class TestClangImport : public TestFixture { } void cxxConstructorDecl2() { - const char clang[] = "`-CXXConstructorDecl 0x1c208c0 col:11 implicit constexpr basic_string 'void (std::basic_string &&)' inline default trivial noexcept-unevaluated 0x1c208c0\n" + const char clang[] = "`-CXXConstructorDecl 0x1c208c0 col:11 implicit constexpr basic_string 'void (std::basic_string &&)' inline default trivial noexcept-unevaluated 0x1c208c0\n" " `-ParmVarDecl 0x1c209f0 col:11 'std::basic_string &&'"; ASSERT_EQUALS("basic_string ( std::basic_string && ) = default ;", parse(clang)); } void cxxConstructExpr1() { - const char clang[] = "`-FunctionDecl 0x2dd7940 col:5 f 'Foo (Foo)'\n" + const char clang[] = "`-FunctionDecl 0x2dd7940 col:5 f 'Foo (Foo)'\n" " |-ParmVarDecl 0x2dd7880 col:11 used foo 'Foo'\n" " `-CompoundStmt 0x2dd80c0 \n" " `-ReturnStmt 0x2dd80a8 \n" @@ -394,7 +394,7 @@ class TestClangImport : public TestFixture { } void cxxForRangeStmt1() { - const char clang[] = "`-FunctionDecl 0x4280820 line:4:6 foo 'void ()'\n" + const char clang[] = "`-FunctionDecl 0x4280820 line:4:6 foo 'void ()'\n" " `-CompoundStmt 0x42810f0 \n" " `-CXXForRangeStmt 0x4281090 \n" " |-DeclStmt 0x4280c30 \n" @@ -430,7 +430,7 @@ class TestClangImport : public TestFixture { void cxxForRangeStmt2() { // clang 9 - const char clang[] = "`-FunctionDecl 0xc15d98 col:6 foo 'void ()'\n" + const char clang[] = "`-FunctionDecl 0xc15d98 col:6 foo 'void ()'\n" " `-CompoundStmt 0xc16668 \n" " `-CXXForRangeStmt 0xc165f8 \n" " |-<<>>\n" @@ -466,7 +466,7 @@ class TestClangImport : public TestFixture { } void cxxFunctionalCastExpr() { - const char clang[] = "`-FunctionDecl 0x156fe98 line:1:5 main 'int (int, char **)'\n" + const char clang[] = "`-FunctionDecl 0x156fe98 line:1:5 main 'int (int, char **)'\n" " |-ParmVarDecl 0x156fd00 col:14 argc 'int'\n" " |-ParmVarDecl 0x156fdb8 col:27 argv 'char **'\n" " `-CompoundStmt 0x1596410 \n" @@ -483,7 +483,7 @@ class TestClangImport : public TestFixture { } void cxxMemberCall() { - const char clang[] = "`-FunctionDecl 0x320dc80 col:6 bar 'void ()'\n" + const char clang[] = "`-FunctionDecl 0x320dc80 col:6 bar 'void ()'\n" " `-CompoundStmt 0x323bb08 \n" " |-DeclStmt 0x323ba40 \n" " | `-VarDecl 0x320df28 col:21 used c 'C':'C' callinit\n" @@ -495,7 +495,7 @@ class TestClangImport : public TestFixture { } void cxxMethodDecl1() { - const char clang[] = "|-CXXMethodDecl 0x55c786f5ad60 col:10 analyzeFile '_Bool (const std::string &, const std::string &, const std::string &, unsigned long long, std::list *)'\n" + const char clang[] = "|-CXXMethodDecl 0x55c786f5ad60 col:10 analyzeFile '_Bool (const std::string &, const std::string &, const std::string &, unsigned long long, std::list *)'\n" "| |-ParmVarDecl 0x55c786f5a4c8 col:41 buildDir 'const std::string &'\n" "| |-ParmVarDecl 0x55c786f5a580 col:70 sourcefile 'const std::string &'\n" "| |-ParmVarDecl 0x55c786f5a638 col:101 cfg 'const std::string &'\n" @@ -506,7 +506,7 @@ class TestClangImport : public TestFixture { } void cxxMethodDecl2() { // "unexpanded" template method - const char clang[] = "`-CXXMethodDecl 0x220ecb0 parent 0x21e4c28 prev 0x21e5338 line:14:1 find 'const typename char_traits<_CharT>::char_type *(const char_traits::char_type *, int, const char_traits::char_type &)'\n" + const char clang[] = "`-CXXMethodDecl 0x220ecb0 parent 0x21e4c28 prev 0x21e5338 line:14:1 find 'const typename char_traits<_CharT>::char_type *(const char_traits::char_type *, int, const char_traits::char_type &)'\n" " `-CompoundStmt 0x220ede0 \n" " `-ReturnStmt 0x220edd0 \n" " `-IntegerLiteral 0x220edb0 'int' 0"; @@ -530,7 +530,7 @@ class TestClangImport : public TestFixture { } void cxxMethodDecl4() { - const char clang[] = "|-ClassTemplateSpecializationDecl 0x15d82f8 line:8:12 struct char_traits definition\n" + const char clang[] = "|-ClassTemplateSpecializationDecl 0x15d82f8 line:8:12 struct char_traits definition\n" "| |-TemplateArgument type 'char'\n" "| | `-BuiltinType 0x15984c0 'char'\n" "| |-CXXRecordDecl 0x15d8520 col:12 implicit struct char_traits\n" @@ -553,7 +553,7 @@ class TestClangImport : public TestFixture { } void cxxNewExpr2() { - const char clang[] = "|-FunctionDecl 0x59a188 line:7:11 f 'struct S *()'\n" + const char clang[] = "|-FunctionDecl 0x59a188 line:7:11 f 'struct S *()'\n" "| `-CompoundStmt 0x5c4318 \n" "| `-ReturnStmt 0x5c4308 \n" "| `-CXXNewExpr 0x5c42c8 'S *' Function 0x59a378 'operator new' 'void *(unsigned long)'\n" @@ -570,7 +570,7 @@ class TestClangImport : public TestFixture { } void cxxOperatorCallExpr() { - const char clang[] = "`-FunctionDecl 0x3c099f0 col:6 foo 'void ()'\n" + const char clang[] = "`-FunctionDecl 0x3c099f0 col:6 foo 'void ()'\n" " `-CompoundStmt 0x3c37308 \n" " |-DeclStmt 0x3c0a060 \n" " | `-VarDecl 0x3c09ae0 col:16 used c 'C' callinit\n" @@ -626,7 +626,7 @@ class TestClangImport : public TestFixture { } void cxxStaticCastExpr3() { - const char clang[] = "`-ClassTemplateSpecializationDecl 0xd842d8 line:4:21 struct char_traits definition\n" + const char clang[] = "`-ClassTemplateSpecializationDecl 0xd842d8 line:4:21 struct char_traits definition\n" " |-TemplateArgument type 'char'\n" " | `-BuiltinType 0xd444c0 'char'\n" " |-CXXRecordDecl 0xd84500 col:21 implicit struct char_traits\n" @@ -680,7 +680,7 @@ class TestClangImport : public TestFixture { } void doStmt() { - const char clang[] = "`-FunctionDecl 0x27fbbc8 col:6 foo 'void ()'\n" + const char clang[] = "`-FunctionDecl 0x27fbbc8 col:6 foo 'void ()'\n" " `-CompoundStmt 0x27fbd08 \n" " `-DoStmt 0x27fbce8 \n" " |-CompoundStmt 0x27fbcb0 \n" @@ -691,7 +691,7 @@ class TestClangImport : public TestFixture { } void enumDecl1() { - const char clang[] = "`-EnumDecl 0x2660660 col:6 referenced abc\n" + const char clang[] = "`-EnumDecl 0x2660660 col:6 referenced abc\n" " |-EnumConstantDecl 0x2660720 col:11 referenced a 'abc'\n" " |-EnumConstantDecl 0x2660768 col:13 b 'abc'\n" " `-EnumConstantDecl 0x26607b0 col:15 c 'abc'"; @@ -762,14 +762,14 @@ class TestClangImport : public TestFixture { } void funcdecl3() { - const char clang[] = "|-FunctionDecl 0x27cb6b8 col:12 __overflow 'int (FILE *, int)' extern\n" + const char clang[] = "|-FunctionDecl 0x27cb6b8 col:12 __overflow 'int (FILE *, int)' extern\n" "| |-ParmVarDecl 0x27cb528 col:30 'FILE *'\n" "| `-ParmVarDecl 0x27cb5a0 col:35 'int'"; ASSERT_EQUALS("int __overflow ( FILE * , int ) ;", parse(clang)); } void funcdecl4() { - const char clang[] = "|-FunctionDecl 0x272bb60 col:15 implicit fwrite 'unsigned long (const void *, unsigned long, unsigned long, FILE *)' extern\n" + const char clang[] = "|-FunctionDecl 0x272bb60 col:15 implicit fwrite 'unsigned long (const void *, unsigned long, unsigned long, FILE *)' extern\n" "| |-ParmVarDecl 0x272cc40 <> 'const void *'\n" "| |-ParmVarDecl 0x272cca0 <> 'unsigned long'\n" "| |-ParmVarDecl 0x272cd00 <> 'unsigned long'\n" @@ -955,7 +955,7 @@ class TestClangImport : public TestFixture { } void unaryExprOrTypeTraitExpr2() { - const char clang[] = "`-VarDecl 0x27c6c00 col:9 x 'int' cinit\n" + const char clang[] = "`-VarDecl 0x27c6c00 col:9 x 'int' cinit\n" " `-ImplicitCastExpr 0x27c6cc8 'int' \n" " `-UnaryExprOrTypeTraitExpr 0x27c6ca8 'unsigned long' sizeof\n" " `-ParenExpr 0x27c6c88 'char [10]' lvalue\n" @@ -1009,12 +1009,12 @@ class TestClangImport : public TestFixture { } void vardecl4() { - const char clang[] = "|-VarDecl 0x23d6c78 col:14 stdin 'FILE *' extern"; + const char clang[] = "|-VarDecl 0x23d6c78 col:14 stdin 'FILE *' extern"; ASSERT_EQUALS("FILE * stdin@1 ;", parse(clang)); } void vardecl5() { - const char clang[] = "|-VarDecl 0x2e31fc0 col:26 sys_errlist 'const char *const []' extern"; + const char clang[] = "|-VarDecl 0x2e31fc0 col:26 sys_errlist 'const char *const []' extern"; ASSERT_EQUALS("const char * const [] sys_errlist@1 ;", parse(clang)); } @@ -1215,7 +1215,7 @@ class TestClangImport : public TestFixture { } void symbolDatabaseNodeType1() { - const char clang[] = "`-FunctionDecl 0x32438c0 line:5:6 foo 'a::b (a::b)'\n" + const char clang[] = "`-FunctionDecl 0x32438c0 line:5:6 foo 'a::b (a::b)'\n" " |-ParmVarDecl 0x32437b0 col:15 used i 'a::b':'long'\n" " `-CompoundStmt 0x3243a60 \n" " `-ReturnStmt 0x3243a48 \n" @@ -1291,7 +1291,7 @@ class TestClangImport : public TestFixture { } void valueType1() { - const char clang[] = "`-FunctionDecl 0x32438c0 line:5:6 foo 'a::b (a::b)'\n" + const char clang[] = "`-FunctionDecl 0x32438c0 line:5:6 foo 'a::b (a::b)'\n" " |-ParmVarDecl 0x32437b0 col:15 used i 'a::b':'long'\n" " `-CompoundStmt 0x3243a60 \n" " `-ReturnStmt 0x3243a48 \n" From 625a90f6a50d5c10e156652d895c5f1181875b28 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 17 Dec 2024 14:22:24 +0100 Subject: [PATCH 2/6] ClangImport: improved AST location parsing and bail out on invalid ones --- lib/clangimport.cpp | 9 ++++++++- test/testclangimport.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 98d162c3007..4ea2cec32a8 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -504,7 +504,9 @@ void clangimport::AstNode::dumpAst(int num, int indent) const void clangimport::AstNode::setLocations(TokenList &tokenList, int file, int line, int col) { - for (const std::string &ext: mExtTokens) { + if (mExtTokens.size() >= 2) + { + const std::string &ext = mExtTokens[1]; if (startsWith(ext, "(ext.substr(5, ext.find_first_of(",>", 5) - 5)); else if (startsWith(ext, "(ext.substr(sep1 + 1, sep2 - sep1 - 1)); } + else { + // these are encountered in every AST dump by some built-in TypedefDecl + if (ext != "<") + throw InternalError(nullptr, "invalid AST location: " + ext, InternalError::AST); + } } } mFile = file; diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 17eb91e11de..7c867a9647d 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -128,6 +128,7 @@ class TestClangImport : public TestFixture { TEST_CASE(symbolDatabaseVariablePointerRef); TEST_CASE(symbolDatabaseNodeType1); TEST_CASE(symbolDatabaseForVariable); + TEST_CASE(stdinLoc); TEST_CASE(valueFlow1); TEST_CASE(valueFlow2); @@ -1320,6 +1321,16 @@ class TestClangImport : public TestFixture { ASSERT_EQUALS("const signed char *", tok->valueType()->str()); } + void stdinLoc() { + // we should never encounter this + /* + int i; + */ + const char clang[] = "`-VarDecl 0x5776bb240470 <:1:1, col:5> col:5 i 'int'\n"; + + ASSERT_THROW_INTERNAL_EQUALS(parse(clang), AST, "invalid AST location: <"); + } + void crash() { const char* clang = "TranslationUnitDecl 0x56037914f998 <> \n" "|-TypedefDecl 0x560379150200 <> implicit __int128_t '__int128'\n" From ca5c2f8833c5aca70cef52ab2d16c570dbe769ff Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 17 Dec 2024 19:52:42 +0100 Subject: [PATCH 3/6] ClangImport: ignore the "prologue" `TypedefDecl` contained entries in each AST dump --- lib/clangimport.cpp | 34 +++++++++++++++++++++++ test/testclangimport.cpp | 60 +++++++++++++++++----------------------- 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 4ea2cec32a8..4f218c8ad1a 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -326,11 +326,14 @@ namespace clangimport { std::string nodeType; std::vector children; + bool isPrologueTypedefDecl() const; void setLocations(TokenList &tokenList, int file, int line, int col); void dumpAst(int num = 0, int indent = 0) const; void createTokens1(TokenList &tokenList) { //dumpAst(); // TODO: reactivate or remove + if (isPrologueTypedefDecl()) + return; if (!tokenList.back()) { setLocations(tokenList, 0, 1, 1); // FIXME: treat as C++ if no filename (i.e. no lang) is specified for now @@ -502,6 +505,37 @@ void clangimport::AstNode::dumpAst(int num, int indent) const } } +bool clangimport::AstNode::isPrologueTypedefDecl() const +{ + // these TypedefDecl are included in *any* AST dump and we should ignore them as they should not be of interest to us + // see https://github.com/llvm/llvm-project/issues/120228#issuecomment-2549212109 for an explanation + if (nodeType != TypedefDecl) + return false; + + // TODO: use different values to indicate ""? + if (mFile != 0 || mLine != 1 || mCol != 1) + return false; + + // TODO: match without using children + if (children.empty()) + return false; + + if (children[0].get()->mExtTokens.size() < 2) + return false; + + const auto& type = children[0].get()->mExtTokens[1]; + if (type == "'__int128'" || + type == "'unsigned __int128'" || + type == "'struct __NSConstantString_tag'" || + type == "'char *'" || + type == "'struct __va_list_tag[1]'") + { + return true; + } + + return false; +} + void clangimport::AstNode::setLocations(TokenList &tokenList, int file, int line, int col) { if (mExtTokens.size() >= 2) diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 7c867a9647d..2ace335a795 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -101,9 +101,7 @@ class TestClangImport : public TestFixture { TEST_CASE(recordDecl1); TEST_CASE(recordDecl2); TEST_CASE(switchStmt); - TEST_CASE(typedefDecl1); - TEST_CASE(typedefDecl2); - TEST_CASE(typedefDecl3); + TEST_CASE(typedefDeclPrologue); TEST_CASE(unaryExprOrTypeTraitExpr1); TEST_CASE(unaryExprOrTypeTraitExpr2); TEST_CASE(unaryOperator); @@ -928,24 +926,30 @@ class TestClangImport : public TestFixture { parse(clang)); } - void typedefDecl1() { - const char clang[] = "|-TypedefDecl 0x2d60180 <> implicit __int128_t '__int128'\n" - "| `-BuiltinType 0x2d5fe80 '__int128'"; - ASSERT_EQUALS("typedef __int128 __int128_t ;", parse(clang)); - } - - void typedefDecl2() { - const char clang[] = "|-TypedefDecl 0x2d604a8 <> implicit __NSConstantString 'struct __NSConstantString_tag'\n" - "| `-RecordType 0x2d602c0 'struct __NSConstantString_tag'\n" - "| `-Record 0x2d60238 '__NSConstantString_tag'"; - ASSERT_EQUALS("typedef struct __NSConstantString_tag __NSConstantString ;", parse(clang)); - } - - void typedefDecl3() { - const char clang[] = "|-TypedefDecl 0x2d60540 <> implicit __builtin_ms_va_list 'char *'\n" - "| `-PointerType 0x2d60500 'char *'\n" - "| `-BuiltinType 0x2d5f980 'char'"; - ASSERT_EQUALS("typedef char * __builtin_ms_va_list ;", parse(clang)); + void typedefDeclPrologue() + { + // these TypedefDecl are included in *any* AST dump and we should ignore them as they should not be of interest to us + // see https://github.com/llvm/llvm-project/issues/120228#issuecomment-2549212109 for an explanation + const char clang[] = + "TranslationUnitDecl 0x60efd80ef9f8 <> \n" + "|-TypedefDecl 0x60efd80f0228 <> implicit __int128_t '__int128'\n" + "| `-BuiltinType 0x60efd80effc0 '__int128'\n" + "|-TypedefDecl 0x60efd80f0298 <> implicit __uint128_t 'unsigned __int128'\n" + "| `-BuiltinType 0x60efd80effe0 'unsigned __int128'\n" + "|-TypedefDecl 0x60efd80f05a0 <> implicit __NSConstantString 'struct __NSConstantString_tag'\n" + "| `-RecordType 0x60efd80f0370 'struct __NSConstantString_tag'\n" + "| `-Record 0x60efd80f02f0 '__NSConstantString_tag'\n" + "|-TypedefDecl 0x60efd80f0648 <> implicit __builtin_ms_va_list 'char *'\n" + "| `-PointerType 0x60efd80f0600 'char *'\n" + "| `-BuiltinType 0x60efd80efaa0 'char'\n" + "|-TypedefDecl 0x60efd80f0940 <> implicit __builtin_va_list 'struct __va_list_tag[1]'\n" + "| `-ConstantArrayType 0x60efd80f08e0 'struct __va_list_tag[1]' 1\n" + "| `-RecordType 0x60efd80f0720 'struct __va_list_tag'\n" + "| `-Record 0x60efd80f06a0 '__va_list_tag'\n" + "`-FunctionDecl 0x60efd8151470 line:1:6 f 'void ()'\n" + "`-CompoundStmt 0x60efd8151560 \n"; + + ASSERT_EQUALS("void f ( ) ;", parse(clang)); } void unaryExprOrTypeTraitExpr1() { @@ -1333,20 +1337,6 @@ class TestClangImport : public TestFixture { void crash() { const char* clang = "TranslationUnitDecl 0x56037914f998 <> \n" - "|-TypedefDecl 0x560379150200 <> implicit __int128_t '__int128'\n" - "| `-BuiltinType 0x56037914ff60 '__int128'\n" - "|-TypedefDecl 0x560379150270 <> implicit __uint128_t 'unsigned __int128'\n" - "| `-BuiltinType 0x56037914ff80 'unsigned __int128'\n" - "|-TypedefDecl 0x5603791505e8 <> implicit __NSConstantString '__NSConstantString_tag'\n" - "| `-RecordType 0x560379150360 '__NSConstantString_tag'\n" - "| `-CXXRecord 0x5603791502c8 '__NSConstantString_tag'\n" - "|-TypedefDecl 0x560379150680 <> implicit __builtin_ms_va_list 'char *'\n" - "| `-PointerType 0x560379150640 'char *'\n" - "| `-BuiltinType 0x56037914fa40 'char'\n" - "|-TypedefDecl 0x5603791968f8 <> implicit __builtin_va_list '__va_list_tag[1]'\n" - "| `-ConstantArrayType 0x5603791968a0 '__va_list_tag[1]' 1 \n" - "| `-RecordType 0x560379150770 '__va_list_tag'\n" - "| `-CXXRecord 0x5603791506d8 '__va_list_tag'\n" "|-ClassTemplateDecl 0x560379196b58 col:37 A\n" "| |-TemplateTypeParmDecl 0x560379196950 col:19 typename depth 0 index 0\n" "| |-TemplateTypeParmDecl 0x5603791969f8 col:29 typename depth 0 index 1\n" From b309c2ddb717fe4ec86840986a575602957ab0ae Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 17 Dec 2024 19:57:04 +0100 Subject: [PATCH 4/6] ClangImport: removed language setting hack --- lib/clangimport.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 4f218c8ad1a..1ef14b73092 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -336,9 +336,6 @@ namespace clangimport { return; if (!tokenList.back()) { setLocations(tokenList, 0, 1, 1); - // FIXME: treat as C++ if no filename (i.e. no lang) is specified for now - if (tokenList.getSourceFilePath().empty()) - tokenList.setLang(Standards::Language::CPP); } else setLocations(tokenList, tokenList.back()->fileIndex(), tokenList.back()->linenr(), 1); From c1af50232a9e869addd0f135ac8f82264f58670f Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 17 Dec 2024 20:01:56 +0100 Subject: [PATCH 5/6] ClangImport: allow completely empty location data --- lib/clangimport.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 1ef14b73092..1cb4a2bce5c 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -555,8 +555,9 @@ void clangimport::AstNode::setLocations(TokenList &tokenList, int file, int line line = strToInt(ext.substr(sep1 + 1, sep2 - sep1 - 1)); } else { - // these are encountered in every AST dump by some built-in TypedefDecl - if (ext != "<") + // "" are encountered in every AST dump by some built-in TypedefDecl + // an completely empty location block was encountered with a CompoundStmt + if (ext != "<" && ext != "<>") throw InternalError(nullptr, "invalid AST location: " + ext, InternalError::AST); } } From f7fb2b355d1cbbe7d875f8f18eec858cebd8d536 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 17 Dec 2024 20:28:29 +0100 Subject: [PATCH 6/6] clangimport.cpp: mitigated `readability-simplify-boolean-expr` clang-tidy warning --- lib/clangimport.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 1cb4a2bce5c..09e2b99e402 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -527,6 +527,7 @@ bool clangimport::AstNode::isPrologueTypedefDecl() const type == "'char *'" || type == "'struct __va_list_tag[1]'") { + // NOLINTNEXTLINE(readability-simplify-boolean-expr) return true; }