Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
}

const char* const startPattern = node->Attribute("startPattern");
if (startPattern)
if (startPattern) {
container.startPattern = startPattern;
container.startPattern2 = container.startPattern + " !!::";
}
const char* const endPattern = node->Attribute("endPattern");
if (endPattern)
container.endPattern = endPattern;
Expand Down Expand Up @@ -1012,10 +1014,7 @@ const Library::Container* Library::detectContainer(const Token* typeStart, bool
if (container.startPattern.empty())
continue;

if (!endsWith(container.startPattern, '<')) {
if (!Token::Match(typeStart, (container.startPattern + " !!::").c_str()))
continue;
} else if (!Token::Match(typeStart, (container.startPattern + " !!::").c_str()))
if (!Token::Match(typeStart, container.startPattern2.c_str()))
continue;

if (!iterator && container.endPattern.empty()) // If endPattern is undefined, it will always match, but itEndPattern has to be defined.
Expand Down
2 changes: 1 addition & 1 deletion lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class CPPCHECKLIB Library {
Action action;
Yield yield;
};
std::string startPattern, endPattern, itEndPattern;
std::string startPattern, startPattern2, endPattern, itEndPattern;
std::map<std::string, Function> functions;
int type_templateArgNo;
int size_templateArgNo;
Expand Down
2 changes: 2 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6113,6 +6113,7 @@ class TestSymbolDatabase: public TestFixture {
Settings sC;
Library::Container c;
c.startPattern = "C";
c.startPattern2 = "C !!::";
sC.library.containers["C"] = c;
ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new","test.cpp",&sC));
ASSERT_EQUALS("container(C) *", typeOf("x=(C*)c;","(","test.cpp",&sC));
Expand All @@ -6122,6 +6123,7 @@ class TestSymbolDatabase: public TestFixture {
Settings set;
Library::Container vector;
vector.startPattern = "Vector";
vector.startPattern2 = "Vector !!::";
vector.type_templateArgNo = 0;
vector.arrayLike_indexOp = true;
set.library.containers["Vector"] = vector;
Expand Down