data: Only show parse errors in project files
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
|
||||
@@ -9,10 +11,12 @@ CxxDiagnosticConsumer::CxxDiagnosticConsumer(
|
||||
clang::raw_ostream &os,
|
||||
clang::DiagnosticOptions *diags,
|
||||
ParserClient* client,
|
||||
const FileManager* fileManager,
|
||||
bool useLogging
|
||||
)
|
||||
: clang::TextDiagnosticPrinter(os, diags)
|
||||
, m_client(client)
|
||||
, m_fileManager(fileManager)
|
||||
, m_isParsingFile(false)
|
||||
, m_useLogging(useLogging)
|
||||
{
|
||||
@@ -70,6 +74,9 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
|
||||
column = presumedLocation.getColumn();
|
||||
}
|
||||
|
||||
m_client->onError(ParseLocation(filePath, line, column), message);
|
||||
if (m_fileManager->hasFilePath(filePath))
|
||||
{
|
||||
m_client->onError(ParseLocation(filePath, line, column), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,20 @@
|
||||
|
||||
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
||||
|
||||
class FileManager;
|
||||
class ParserClient;
|
||||
|
||||
class CxxDiagnosticConsumer
|
||||
: public clang::TextDiagnosticPrinter
|
||||
{
|
||||
public:
|
||||
CxxDiagnosticConsumer(clang::raw_ostream &os, clang::DiagnosticOptions *diags, ParserClient* client, bool useLogging = true);
|
||||
CxxDiagnosticConsumer(
|
||||
clang::raw_ostream &os,
|
||||
clang::DiagnosticOptions *diags,
|
||||
ParserClient* client,
|
||||
const FileManager* fileManager,
|
||||
bool useLogging = true
|
||||
);
|
||||
|
||||
void BeginSourceFile(const clang::LangOptions& langOptions, const clang::Preprocessor* preProcessor);
|
||||
void EndSourceFile();
|
||||
@@ -18,6 +25,7 @@ public:
|
||||
|
||||
private:
|
||||
ParserClient* m_client;
|
||||
const FileManager* m_fileManager;
|
||||
bool m_isParsingFile;
|
||||
bool m_useLogging;
|
||||
};
|
||||
|
||||
@@ -165,7 +165,8 @@ std::shared_ptr<clang::tooling::FixedCompilationDatabase> CxxParser::getCompilat
|
||||
std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(const Arguments& arguments) const
|
||||
{
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
|
||||
return std::make_shared<CxxDiagnosticConsumer>(llvm::errs(), &*options, m_client, arguments.logErrors);
|
||||
return std::make_shared<CxxDiagnosticConsumer>(
|
||||
llvm::errs(), &*options, m_client, m_fileRegister->getFileManager(), arguments.logErrors);
|
||||
}
|
||||
|
||||
void CxxParser::setupParsing(const std::vector<FilePath>& filePaths, const Arguments& arguments)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "data/Storage.h"
|
||||
#include "data/type/DataType.h"
|
||||
#include "data/type/NamedDataType.h"
|
||||
|
||||
class StorageTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user