Skip to content

Commit 2c54f31

Browse files
Fix #12251 internalError while cppcheck tries to parse Clang AST (#5755)
1 parent 30e8814 commit 2c54f31

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/clangimport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ void clangimport::AstNode::setLocations(TokenList *tokenList, int file, int line
509509
} else if (ext[0] == '<') {
510510
const std::string::size_type colon = ext.find(':');
511511
if (colon != std::string::npos) {
512-
const bool windowsPath = colon == 2 && ext.size() > 4 && ext[3] == '\\';
512+
const bool windowsPath = colon == 2 && ext.size() > 3 && ext[2] == ':';
513513
const std::string::size_type sep1 = windowsPath ? ext.find(':', 4) : colon;
514514
const std::string::size_type sep2 = ext.find(':', sep1 + 1);
515515
file = tokenList->appendFileIfNew(ext.substr(1, sep1 - 1));

test/testclangimport.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,9 @@ class TestClangImport : public TestFixture {
589589

590590
clang = "`-CXXRecordDecl 0x34cc5f8 <C:\\Foo\\Bar Baz\\1.cpp:2:1, col:7> col:7 class Foo";
591591
ASSERT_EQUALS("class Foo ;", parse(clang));
592+
593+
clang = "`-CXXRecordDecl 0x34cc5f8 <C:/Foo/Bar Baz/1.cpp:2:1, col:7> col:7 class Foo";
594+
ASSERT_EQUALS("class Foo ;", parse(clang));
592595
}
593596

594597
void cxxRecordDecl2() {

0 commit comments

Comments
 (0)