diff options
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbol.cpp | 4 | ||||
-rw-r--r-- | tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/libs/3rdparty/cplusplus/Symbol.cpp b/src/libs/3rdparty/cplusplus/Symbol.cpp index ae20b14bb7..e98b33a8a7 100644 --- a/src/libs/3rdparty/cplusplus/Symbol.cpp +++ b/src/libs/3rdparty/cplusplus/Symbol.cpp @@ -191,10 +191,10 @@ const StringLiteral *Symbol::fileId() const } const char *Symbol::fileName() const -{ return fileId()->chars(); } +{ return _fileId ? _fileId->chars() : ""; } unsigned Symbol::fileNameLength() const -{ return fileId()->size(); } +{ return _fileId ? _fileId->size() : 0; } const Name *Symbol::unqualifiedName() const { diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp index d2de76e4d8..cf26114d9a 100644 --- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp +++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp @@ -219,6 +219,8 @@ private slots: void test_checksymbols_infiniteLoop_data(); void test_checksymbols_infiniteLoop(); + void test_checkForValidSymbolFileId(); + void test_parentOfBlock(); void findField(); @@ -1165,6 +1167,33 @@ void tst_CheckSymbols::test_checksymbols_infiniteLoop() TestCase::runCheckSymbols(document1, snapshot); } +void tst_CheckSymbols::test_checkForValidSymbolFileId() +{ + const QByteArray contents = + "constexpr int parent_of(const int f) { return 1; }\n" + "\n" + "template <typename T> struct wrapper { const T* ptr; };\n" + "template <int> struct Dummy;\n" + "\n" + "namespace impl {\n" + " template <int f>\n" + " struct dummy_impl {\n" + " wrapper<Dummy<parent_of(f)>> parent;\n" + " };\n" + "}\n" + "\n" + "template <int f>\n" + "struct Dummy : impl::dummy_impl<f> {};\n" + "\n" + "void client()\n" + "{\n" + " wrapper<Dummy<1>> a;\n" + " a.ptr->parent.ptr;\n" + "}\n"; + + BaseTestCase tc(contents); +} + void tst_CheckSymbols::test_parentOfBlock() { const QByteArray source = "void C::f()\n" |