logic: Cxx destructor decl fixes

* omit visiting a type in the name of a CxxDestructorDecl (which recorded a type reference)
* fixed range of names for Cxx destructors and overleaded operators.
This commit is contained in:
mlangkabel
2017-09-11 15:40:26 +02:00
parent 41348f5130
commit 64a97d37f1
5 changed files with 41 additions and 13 deletions
+8 -6
View File
@@ -281,13 +281,15 @@ int main(int argc, char *argv[])
else
{
#ifdef _WIN32
HWND consoleWnd = GetConsoleWindow();
DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
if (GetCurrentProcessId() == dwProcessId)
{
// Sourcetrail has not been started from console and thus has it's own console
ShowWindow(consoleWnd, SW_HIDE);
HWND consoleWnd = GetConsoleWindow();
DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
if (GetCurrentProcessId() == dwProcessId)
{
// Sourcetrail has not been started from console and thus has it's own console
ShowWindow(consoleWnd, SW_HIDE);
}
}
#endif
QtApplication qtApp(argc, argv);
+12 -3
View File
@@ -461,6 +461,12 @@ bool CxxAstVisitor::TraverseBinComma(clang::BinaryOperator* s)
return true;
}
bool CxxAstVisitor::TraverseDeclarationNameInfo(clang::DeclarationNameInfo NameInfo)
{
// we don't visit any children here
return true;
}
void CxxAstVisitor::traverseDeclContextHelper(clang::DeclContext* d)
{
if (!d)
@@ -682,15 +688,18 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceRange& sourceRa
{
const clang::SourceManager& sourceManager = m_astContext->getSourceManager();
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(sourceRange.getBegin(), false);
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false);
const clang::SourceLocation startLoc = sourceRange.getBegin();
const clang::SourceLocation endLoc = m_preprocessor->getLocForEndOfToken(sourceRange.getEnd());
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(startLoc, false);
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(endLoc, false);
parseLocation = ParseLocation(
m_canonicalFilePathCache->getValue(presumedBegin.getFilename()),
presumedBegin.getLine(),
presumedBegin.getColumn(),
presumedEnd.getLine(),
presumedEnd.getColumn()
presumedEnd.getColumn() - 1
);
}
return parseLocation;
@@ -91,6 +91,8 @@ public:
virtual bool TraverseLambdaCapture(clang::LambdaExpr* lambdaExpr, const clang::LambdaCapture* capture, clang::Expr *Init);
virtual bool TraverseBinComma(clang::BinaryOperator* s);
virtual bool TraverseDeclarationNameInfo(clang::DeclarationNameInfo NameInfo);
#define OPERATOR(NAME) virtual bool TraverseBin##NAME##Assign(clang::CompoundAssignOperator *s) { return TraverseAssignCommon(s); }
OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub)
OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor)
@@ -230,7 +230,7 @@ void CxxAstVisitorComponentIndexer::visitFunctionDecl(clang::FunctionDecl* d)
m_client->recordSymbol(
getAstVisitor()->getDeclNameCache()->getValue(d),
clang::isa<clang::CXXMethodDecl>(d) ? SYMBOL_METHOD : SYMBOL_FUNCTION,
getParseLocation(d->getLocation()),
getParseLocation(d->getNameInfo().getSourceRange()),
getParseLocationOfFunctionBody(d),
utility::convertAccessSpecifier(d->getAccess()),
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
+18 -3
View File
@@ -186,6 +186,21 @@ public:
));
}
void test_cxx_parser_finds_overloaded_operator_declaration()
{
std::shared_ptr<TestParserClient> client = parseCode(
"class B\n"
"{\n"
"public:\n"
" B& operator=(const B& other);\n"
"};\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->methods, "public B & B::operator=(const B &) <4:5 4:13>"
));
}
void test_cxx_parser_finds_method_declaration_and_definition()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -1295,8 +1310,8 @@ public:
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(client->methods, "public void TestClass::TestClass() <1:7 <1:7 1:15> 1:7>"));
TS_ASSERT(utility::containsElement<std::string>(client->methods, "public void TestClass::TestClass(const TestClass &) <1:7 <1:7 1:15> 1:7>"));
TS_ASSERT(utility::containsElement<std::string>(client->methods, "public void TestClass::TestClass() <1:7 <1:7 1:15> 1:15>"));
TS_ASSERT(utility::containsElement<std::string>(client->methods, "public void TestClass::TestClass(const TestClass &) <1:7 <1:7 1:15> 1:15>"));
TS_ASSERT(utility::containsElement<std::string>(client->methods, "public void TestClass::TestClass(TestClass &) <1:7 1:15>"));
}
@@ -3394,7 +3409,7 @@ public:
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
TS_ASSERT_EQUALS(client->calls.size(), 3);
TS_ASSERT_EQUALS(client->usages.size(), 3);
TS_ASSERT_EQUALS(client->typeUses.size(), 17);
TS_ASSERT_EQUALS(client->typeUses.size(), 16);
TS_ASSERT_EQUALS(client->files.size(), 2);
TS_ASSERT_EQUALS(client->includes.size(), 1);