data: filename info

* Changed the TokenLocation of TemplateArguments to have at least a valid file name.
* Extended name of anonymous namespace by the containing file's name.
* Adjusted tests to reflect these changes.
This commit is contained in:
malte_langkabel
2015-02-27 16:07:51 +01:00
parent d0c92a6553
commit 5370541a0f
4 changed files with 15 additions and 7 deletions
+4 -1
View File
@@ -310,7 +310,10 @@ Id Storage::onNamespaceParsed(
log("namespace", utility::join(nameHierarchy, "::"), location);
Node* node = addNodeHierarchy(Node::NODE_NAMESPACE, nameHierarchy);
addTokenLocation(node, location);
if (location.isValid())
{
addTokenLocation(node, location);
}
addTokenLocation(node, scopeLocation, true);
return node->getId();
+5 -2
View File
@@ -331,14 +331,17 @@ bool ASTVisitor::VisitClassTemplateDecl(clang::ClassTemplateDecl* declaration)
getParseLocationForNamedDecl(*it), specializedRecordNameHierarchy, specializedRecordType, specializationParentNameHierarchy
);
std::string specializationFilePath = getParseLocationForNamedDecl(specializationDecl).filePath;
const clang::TemplateArgumentList &argList = specializationDecl->getTemplateArgs();
for (size_t i = 0; i < argList.size(); i++)
{
std::vector<std::string> argumentNameHierarchy = utility::templateArgumentToDataType(argList.get(i)).getTypeNameHierarchy();
if (argumentNameHierarchy.size()) // FIXME: Some TemplateArgument kinds are not handled yet.
{
m_client->onTemplateArgumentParsed(
ParseLocation(), // TODO: Find a valid ParseLocation here!
ParseLocation(specializationFilePath, 0, 0), // TODO: Find a valid ParseLocation here!
argumentNameHierarchy,
specializedRecordNameHierarchy
);
@@ -457,7 +460,7 @@ bool ASTVisitor::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl *declarat
const clang::QualType argumentType = argument.getAsType();
m_client->onTemplateArgumentParsed(
ParseLocation(), // TODO: get ParseLocation
ParseLocation(specializedFunctionLocation.filePath, 0, 0), // TODO: Find a valid ParseLocation here!
utility::qualTypeToDataType(argumentType).getTypeNameHierarchy(),
specializedFunction.nameHierarchy);
}
+3 -1
View File
@@ -299,7 +299,9 @@ namespace utility
}
else if (clang::isa<clang::NamespaceDecl>(declaration) && clang::dyn_cast<clang::NamespaceDecl>(declaration)->isAnonymousNamespace())
{
declName = "(anonymous namespace)";
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart());
declName = "anonymous namespace (" + std::string(presumedBegin.getFilename()) + ")";
}
return declName;
}
+3 -3
View File
@@ -213,7 +213,7 @@ public:
);
TS_ASSERT_EQUALS(client->functions.size(), 1);
TS_ASSERT_EQUALS(client->functions[0], "int (anonymous namespace)::sum(int, int) <3:6 3:8>");
TS_ASSERT_EQUALS(client->functions[0], "int anonymous namespace (input.cc)::sum(int, int) <3:6 3:8>");
}
void test_cxx_parser_finds_static_function_in_global_namespace()
@@ -326,7 +326,7 @@ public:
);
TS_ASSERT_EQUALS(client->namespaces.size(), 1);
TS_ASSERT_EQUALS(client->namespaces[0], "(anonymous namespace) <1:1 3:1>");
TS_ASSERT_EQUALS(client->namespaces[0], "anonymous namespace (input.cc) <1:1 3:1>");
}
void test_cxx_parser_finds_nested_named_namespace()
@@ -434,7 +434,7 @@ public:
);
TS_ASSERT_EQUALS(client->typedefs.size(), 1);
TS_ASSERT_EQUALS(client->typedefs[0], "unsigned int -> (anonymous namespace)::uint <3:23 3:26>");
TS_ASSERT_EQUALS(client->typedefs[0], "unsigned int -> anonymous namespace (input.cc)::uint <3:23 3:26>");
}
void test_cxx_parser_finds_typedef_that_uses_type_defined_in_named_namespace()