File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1892,6 +1892,8 @@ bool Library::isSmartPointer(const Token* tok) const
1892
1892
1893
1893
const Library::SmartPointer* Library::detectSmartPointer (const Token* tok, bool withoutStd) const
1894
1894
{
1895
+ if (!tok)
1896
+ return nullptr ;
1895
1897
std::string typestr = withoutStd ? " std::" : " " ;
1896
1898
if (tok->str () == " ::" )
1897
1899
tok = tok->next ();
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class TestLibrary : public TestFixture {
69
69
TEST_CASE (version);
70
70
TEST_CASE (loadLibErrors);
71
71
TEST_CASE (loadLibCombinations);
72
+ TEST_CASE (smartpointer);
72
73
}
73
74
74
75
void isCompliantValidationExpression () const {
@@ -868,6 +869,8 @@ class TestLibrary : public TestFixture {
868
869
ASSERT_EQUALS (F.endPattern , " " );
869
870
ASSERT_EQUALS (F.itEndPattern , " :: iterator" );
870
871
872
+ ASSERT (!library.detectContainerOrIterator (nullptr ));
873
+
871
874
{
872
875
const SimpleTokenizer var (*this , " std::A<int> a;" );
873
876
ASSERT_EQUALS (&A, library.detectContainer (var.tokens ()));
@@ -1140,6 +1143,15 @@ class TestLibrary : public TestFixture {
1140
1143
ASSERT_EQUALS (s.library .defines ().empty (), false );
1141
1144
}
1142
1145
}
1146
+
1147
+ void smartpointer () const {
1148
+ const Settings s = settingsBuilder ().library (" std.cfg" ).build ();
1149
+ const Library& library = s.library ;
1150
+
1151
+ ASSERT (!library.detectSmartPointer (nullptr ));
1152
+
1153
+ // TODO: add more tests
1154
+ }
1143
1155
};
1144
1156
1145
1157
REGISTER_TEST (TestLibrary)
Original file line number Diff line number Diff line change @@ -612,6 +612,8 @@ class TestSymbolDatabase : public TestFixture {
612
612
TEST_CASE(testValuetypeOriginalName);
613
613
614
614
TEST_CASE(dumpFriend); // Check if isFriend added to dump file
615
+
616
+ TEST_CASE(smartPointerLookupCtor); // #13719);
615
617
}
616
618
617
619
void array() {
@@ -11190,6 +11192,14 @@ class TestSymbolDatabase : public TestFixture {
11190
11192
db->printXml(ostr);
11191
11193
ASSERT(ostr.str().find(" isFriend=\"true\"") != std::string::npos);
11192
11194
}
11195
+
11196
+ void smartPointerLookupCtor() { // #13719
11197
+ // do not crash in smartpointer lookup
11198
+ GET_SYMBOL_DB("struct S { int v; S(int i); };\n"
11199
+ "void f() { S(0).v; }");
11200
+
11201
+ ASSERT(db);
11202
+ }
11193
11203
};
11194
11204
11195
11205
REGISTER_TEST(TestSymbolDatabase)
You can’t perform that action at this time.
0 commit comments