logic: C/C++ errors without location are now recorded for current main file

* such an error occurrs if a "-include" flag is provided with a non-existing file"
This commit is contained in:
mlangkabel
2018-05-11 11:22:39 +02:00
parent e47bd10096
commit ea7f900e81
3 changed files with 21 additions and 2 deletions
@@ -90,6 +90,11 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
}
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(sourceManager.getFileID(loc));
if (fileEntry == nullptr || !fileEntry->isValid())
{
fileEntry = sourceManager.getFileEntryForID(sourceManager.getMainFileID());
}
if (fileEntry != nullptr && fileEntry->isValid())
{
filePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
+12 -1
View File
@@ -4057,6 +4057,17 @@ public:
));
}
void test_cxx_parser_catches_error_in_macro_expasdsadansion()
{
std::shared_ptr<TestParserClient> client = parseCode(
"void foo() {} \n", { L"-include nothing" }
);
TS_ASSERT(utility::containsElement<std::wstring>(
client->errors, L"' nothing' file not found <1:10 1:10>"
));
}
void test_cxx_parser_catches_error_in_macro_expansion()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -4068,7 +4079,7 @@ public:
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(
+4 -1
View File
@@ -168,7 +168,10 @@ private:
bool fatal,
bool indexed) override
{
errors.push_back(addLocationSuffix(message, location));
if (location.isValid())
{
errors.push_back(addLocationSuffix(message, location));
}
}
std::vector<std::wstring>* getBinForSymbolKind(SymbolKind symbolType)