From 2c54f31bfef1974054d4a6784f7bbeaa109d1c6a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 12 Dec 2023 20:47:58 +0100 Subject: [PATCH] Fix #12251 internalError while cppcheck tries to parse Clang AST (#5755) --- lib/clangimport.cpp | 2 +- test/testclangimport.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 805741fd00b..a0d2bba5533 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -509,7 +509,7 @@ void clangimport::AstNode::setLocations(TokenList *tokenList, int file, int line } else if (ext[0] == '<') { const std::string::size_type colon = ext.find(':'); if (colon != std::string::npos) { - const bool windowsPath = colon == 2 && ext.size() > 4 && ext[3] == '\\'; + const bool windowsPath = colon == 2 && ext.size() > 3 && ext[2] == ':'; const std::string::size_type sep1 = windowsPath ? ext.find(':', 4) : colon; const std::string::size_type sep2 = ext.find(':', sep1 + 1); file = tokenList->appendFileIfNew(ext.substr(1, sep1 - 1)); diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index f92b8ef98f4..e301c41db02 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -589,6 +589,9 @@ class TestClangImport : public TestFixture { clang = "`-CXXRecordDecl 0x34cc5f8 col:7 class Foo"; ASSERT_EQUALS("class Foo ;", parse(clang)); + + clang = "`-CXXRecordDecl 0x34cc5f8 col:7 class Foo"; + ASSERT_EQUALS("class Foo ;", parse(clang)); } void cxxRecordDecl2() {