logic: fixed c/c++ indexing errors are not recorded inside macro expansion (issue #580)
This commit is contained in:
@@ -83,7 +83,13 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
|
||||
column = presumedLocation.getColumn();
|
||||
}
|
||||
|
||||
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(sourceManager.getFileID(info.getLocation()));
|
||||
clang::SourceLocation loc = sourceManager.getExpansionLoc(info.getLocation());
|
||||
if (loc.isInvalid())
|
||||
{
|
||||
loc = info.getLocation();
|
||||
}
|
||||
|
||||
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(sourceManager.getFileID(loc));
|
||||
if (fileEntry != nullptr && fileEntry->isValid())
|
||||
{
|
||||
filePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
|
||||
@@ -4057,6 +4057,18 @@ public:
|
||||
));
|
||||
}
|
||||
|
||||
void test_cxx_parser_catches_error_in_macro_expansion()
|
||||
{
|
||||
std::shared_ptr<TestParserClient> client = parseCode(
|
||||
"#define MACRO_WITH_NONEXISTING_PATH \"this_path_does_not_exist.txt\"\n"
|
||||
"#include MACRO_WITH_NONEXISTING_PATH\n"
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->errors, L"'this_path_does_not_exist.txt' file not found <2:10 2:10>"
|
||||
));
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_location_of_line_comment()
|
||||
{
|
||||
std::shared_ptr<TestParserClient> client = parseCode(
|
||||
|
||||
Reference in New Issue
Block a user