data: Fixed macro expands not saved within macro expands

This commit is contained in:
Eberhard Graether
2016-06-10 22:24:14 +02:00
parent 7e3b2622ec
commit 6821fd1c9a
2 changed files with 18 additions and 2 deletions
@@ -96,7 +96,7 @@ void PreprocessorCallbacks::MacroExpands(
const clang::Token& macroNameToken, const clang::MacroDefinition& macroDirective,
clang::SourceRange range, const clang::MacroArgs* args
){
const std::string& fileStr = m_sourceManager.getFilename(macroNameToken.getLocation());
const std::string& fileStr = m_sourceManager.getFilename(m_sourceManager.getFileLoc(macroNameToken.getLocation()));
if (!fileStr.size())
{
return;
@@ -116,7 +116,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token& macroN
{
clang::SourceLocation location = macroNameTok.getLocation();
return ParseLocation(
m_sourceManager.getFilename(location),
m_sourceManager.getFilename(m_sourceManager.getFileLoc(location)),
m_sourceManager.getSpellingLineNumber(location),
m_sourceManager.getSpellingColumnNumber(location),
m_sourceManager.getSpellingLineNumber(macroNameTok.getEndLoc()),
+16
View File
@@ -1781,6 +1781,22 @@ public:
TS_ASSERT_EQUALS(client->macroUses[0], "PI <4:12 4:13>");
}
void test_cxx_parser_finds_macro_expand_within_macro()
{
std::shared_ptr<TestParserClient> client = parseCode(
"#define PI 3.14159265359\n"
"#define TAU (2 * PI)\n"
"void test()\n"
"{\n"
"double i = TAU;"
"};\n"
);
TS_ASSERT_EQUALS(client->macroUses.size(), 2);
TS_ASSERT_EQUALS(client->macroUses[0], "TAU <5:12 5:14>");
TS_ASSERT_EQUALS(client->macroUses[1], "PI <2:18 2:19>");
}
void test_cxx_parser_finds_usage_of_template_template_parameter_of_template_class_specialized_with_concrete_type()
{
std::shared_ptr<TestParserClient> client = parseCode(