Skip to content

Commit

Permalink
Fix #12251 internalError while cppcheck tries to parse Clang AST (dan…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Dec 12, 2023
1 parent 30e8814 commit 2c54f31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions test/testclangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ class TestClangImport : public TestFixture {

clang = "`-CXXRecordDecl 0x34cc5f8 <C:\\Foo\\Bar Baz\\1.cpp:2:1, col:7> col:7 class Foo";
ASSERT_EQUALS("class Foo ;", parse(clang));

clang = "`-CXXRecordDecl 0x34cc5f8 <C:/Foo/Bar Baz/1.cpp:2:1, col:7> col:7 class Foo";
ASSERT_EQUALS("class Foo ;", parse(clang));
}

void cxxRecordDecl2() {
Expand Down

0 comments on commit 2c54f31

Please sign in to comment.