diff --git a/bin/app/user/ApplicationSettings_template.xml b/bin/app/user/ApplicationSettings_template.xml index f3eb6d79..26e39e9b 100644 --- a/bin/app/user/ApplicationSettings_template.xml +++ b/bin/app/user/ApplicationSettings_template.xml @@ -30,6 +30,7 @@ + diff --git a/src/lib/component/controller/FeatureController.cpp b/src/lib/component/controller/FeatureController.cpp index cf84aaee..4ae381b4 100644 --- a/src/lib/component/controller/FeatureController.cpp +++ b/src/lib/component/controller/FeatureController.cpp @@ -131,7 +131,7 @@ void FeatureController::handleMessage(MessageSearch* message) case SearchMatch::COMMAND_ERROR: { - MessageShowErrors msg(ErrorCountInfo(-1, 0)); + MessageShowErrors msg(m_storageAccess->getErrorCount()); msg.setIsReplayed(message->isReplayed()); msg.dispatchImmediately(); return; diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 49d126e2..5a505b4c 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -43,12 +43,14 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message) MessageStatus(status, false).dispatch(); } +void StatusBarController::handleMessage(MessageRefresh* message) +{ + getView()->setErrorCount(m_storageAccess->getErrorCount()); +} + void StatusBarController::handleMessage(MessageShowErrors* message) { - if (message->errorCount.total >= 0) - { - getView()->setErrorCount(message->errorCount); - } + getView()->setErrorCount(message->errorCount); } void StatusBarController::handleMessage(MessageStatus* message) diff --git a/src/lib/component/controller/StatusBarController.h b/src/lib/component/controller/StatusBarController.h index 60320819..8f0cedbc 100644 --- a/src/lib/component/controller/StatusBarController.h +++ b/src/lib/component/controller/StatusBarController.h @@ -8,6 +8,7 @@ #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/MessageClearErrorCount.h" #include "utility/messaging/type/MessageFinishedParsing.h" +#include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageShowErrors.h" #include "utility/messaging/type/MessageStatus.h" @@ -18,6 +19,7 @@ class StatusBarController : public Controller , public MessageListener , public MessageListener + , public MessageListener , public MessageListener , public MessageListener { @@ -32,6 +34,7 @@ public: private: virtual void handleMessage(MessageClearErrorCount* message); virtual void handleMessage(MessageFinishedParsing* message); + virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageShowErrors* message); virtual void handleMessage(MessageStatus* message); diff --git a/src/lib/data/ErrorCountInfo.h b/src/lib/data/ErrorCountInfo.h index f9a940aa..299db8c2 100644 --- a/src/lib/data/ErrorCountInfo.h +++ b/src/lib/data/ErrorCountInfo.h @@ -8,12 +8,12 @@ struct ErrorCountInfo , fatal(0) {} - ErrorCountInfo(int total, size_t fatal) + ErrorCountInfo(size_t total, size_t fatal) : total(total) , fatal(fatal) {} - int total; + size_t total; size_t fatal; }; diff --git a/src/lib/data/IntermediateStorage.cpp b/src/lib/data/IntermediateStorage.cpp index e45c2800..f765deed 100644 --- a/src/lib/data/IntermediateStorage.cpp +++ b/src/lib/data/IntermediateStorage.cpp @@ -138,11 +138,12 @@ void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint )); } -void IntermediateStorage::addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol) +void IntermediateStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol) { m_errors.push_back(StorageError( message, fatal, + indexed, filePath, startLine, startCol diff --git a/src/lib/data/IntermediateStorage.h b/src/lib/data/IntermediateStorage.h index 4202d1ed..4e03fac7 100644 --- a/src/lib/data/IntermediateStorage.h +++ b/src/lib/data/IntermediateStorage.h @@ -21,7 +21,7 @@ public: virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); virtual void addComponentAccess(Id edgeId , int type); virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); - virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol); + virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol); virtual void forEachFile(std::function callback) const; virtual void forEachNode(std::function callback) const; diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index 815ac8cd..efaed92e 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -136,11 +136,12 @@ void PersistentStorage::addCommentLocation(Id fileNodeId, uint startLine, uint s } void PersistentStorage::addError( - const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol) + const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol) { m_sqliteStorage.addError( message, fatal, + indexed, filePath, startLine, startCol @@ -224,14 +225,12 @@ void PersistentStorage::finishInjection() m_sqliteStorage.commitTransaction(); ErrorCountInfo errorCount = getErrorCount(); - if (m_preInjectionErrorCount != -1 && - m_preInjectionErrorCount != errorCount.total) + if (m_preInjectionErrorCount != errorCount.total) { MessageShowErrors msg(errorCount); msg.setSendAsTask(false); msg.dispatchImmediately(); } - m_preInjectionErrorCount = -1; } FilePath PersistentStorage::getDbFilePath() const @@ -988,14 +987,19 @@ std::shared_ptr PersistentStorage::getErrorTokenLocatio std::shared_ptr errorCollection = std::make_shared(); + bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors(); + std::vector storageErrors = m_sqliteStorage.getAllErrors(); for (size_t i = 0; i < storageErrors.size(); i++) { const StorageError& error = storageErrors[i]; - errorCollection->addTokenLocation( - i, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber - )->setType(LOCATION_ERROR); - errors->push_back(ErrorInfo(error.message, error.filePath, i, error.fatal)); + if (error.fatal || error.indexed || showExternalNonFatalErrors) + { + errorCollection->addTokenLocation( + i, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber + )->setType(LOCATION_ERROR); + errors->push_back(ErrorInfo(error.message, error.filePath, i, error.fatal)); + } } return errorCollection; @@ -1048,7 +1052,25 @@ std::vector PersistentStorage::getFileInfosForFilePaths(const std::vec ErrorCountInfo PersistentStorage::getErrorCount() const { - return ErrorCountInfo(m_sqliteStorage.getAllErrors().size(), m_sqliteStorage.getFatalErrors().size()); + bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors(); + + ErrorCountInfo info; + + std::vector storageErrors = m_sqliteStorage.getAllErrors(); + for (const StorageError& error : storageErrors) + { + if (error.fatal || error.indexed || showExternalNonFatalErrors) + { + info.total++; + } + + if (error.fatal) + { + info.fatal++; + } + } + + return info; } StorageStats PersistentStorage::getStorageStats() const diff --git a/src/lib/data/PersistentStorage.h b/src/lib/data/PersistentStorage.h index be76dc39..b6caf1d2 100644 --- a/src/lib/data/PersistentStorage.h +++ b/src/lib/data/PersistentStorage.h @@ -34,7 +34,7 @@ public: virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); virtual void addComponentAccess(Id edgeId , int type); virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); - virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol); + virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol); virtual void forEachFile(std::function callback) const; virtual void forEachNode(std::function callback) const; @@ -139,7 +139,7 @@ private: void log(std::string type, std::string str, const ParseLocation& location) const; - int m_preInjectionErrorCount; + size_t m_preInjectionErrorCount; SearchIndex m_commandIndex; SearchIndex m_elementIndex; diff --git a/src/lib/data/SqliteStorage.cpp b/src/lib/data/SqliteStorage.cpp index cb15b7e1..ec95e45b 100644 --- a/src/lib/data/SqliteStorage.cpp +++ b/src/lib/data/SqliteStorage.cpp @@ -200,7 +200,7 @@ Id SqliteStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCo return m_database.lastRowId(); } -Id SqliteStorage::addError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber) +Id SqliteStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber) { std::string sanitizedMessage = utility::replace((fatal ? "Fatal: " : "Error: ") + message, "'", "''"); @@ -226,8 +226,8 @@ Id SqliteStorage::addError(const std::string& message, bool fatal, const std::st stmt.finalize(); stmt = m_database.compileStatement(( - "INSERT INTO error(message, fatal, file_path, line_number, column_number) " - "VALUES (?, " + std::to_string(fatal) + ", '" + filePath + + "INSERT INTO error(message, fatal, indexed, file_path, line_number, column_number) " + "VALUES (?, " + std::to_string(fatal) + ", " + std::to_string(indexed) + ", '" + filePath + "', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");" ).c_str()); @@ -550,11 +550,6 @@ std::vector SqliteStorage::getCommentLocationsInFile(con return getAll("WHERE file_node_id == " + std::to_string(fileNodeId)); } -std::vector SqliteStorage::getFatalErrors() const -{ - return getAll("WHERE fatal == 1"); -} - std::vector SqliteStorage::getAllFiles() const { return getAll(""); @@ -752,6 +747,7 @@ void SqliteStorage::setupTables() "id INTEGER NOT NULL, " "message TEXT, " "fatal INTEGER NOT NULL, " + "indexed INTEGER NOT NULL, " "file_path TEXT, " "line_number INTEGER, " "column_number INTEGER, " @@ -990,7 +986,7 @@ template <> std::vector SqliteStorage::getAll(const std::string& query) const { CppSQLite3Query q = m_database.execQuery(( - "SELECT message, fatal, file_path, line_number, column_number FROM error " + query + ";" + "SELECT message, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";" ).c_str()); std::vector errors; @@ -998,13 +994,14 @@ std::vector SqliteStorage::getAll(const std::string& { const std::string message = q.getStringField(0, ""); const bool fatal = q.getIntField(1, 0); - const std::string filePath = q.getStringField(2, ""); - const int lineNumber = q.getIntField(3, -1); - const int columnNumber = q.getIntField(4, -1); + const bool indexed = q.getIntField(2, 0); + const std::string filePath = q.getStringField(3, ""); + const int lineNumber = q.getIntField(4, -1); + const int columnNumber = q.getIntField(5, -1); if (lineNumber != -1 && columnNumber != -1) { - errors.push_back(StorageError(message, fatal, filePath, lineNumber, columnNumber)); + errors.push_back(StorageError(message, fatal, indexed, filePath, lineNumber, columnNumber)); } q.nextRow(); diff --git a/src/lib/data/SqliteStorage.h b/src/lib/data/SqliteStorage.h index 0a847bc6..fa9a5412 100644 --- a/src/lib/data/SqliteStorage.h +++ b/src/lib/data/SqliteStorage.h @@ -44,7 +44,7 @@ public: Id addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); Id addComponentAccess(Id memberEdgeId, int type); Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); - Id addError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber); + Id addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber); void removeElement(Id id); void removeElements(const std::vector& ids); @@ -101,7 +101,6 @@ public: std::vector getFullTextSearch(const std::string& searchTerm) const; std::vector getCommentLocationsInFile(const FilePath& filePath) const; - std::vector getFatalErrors() const; std::vector getAllFiles() const; std::vector getAllNodes() const; diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index 0554f300..17d1d8b6 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -170,6 +170,7 @@ void Storage::inject(Storage* injected) addError( injectedData.message, injectedData.fatal, + injectedData.indexed, injectedData.filePath, injectedData.lineNumber, injectedData.columnNumber diff --git a/src/lib/data/Storage.h b/src/lib/data/Storage.h index e2405b4b..23c37b9e 100644 --- a/src/lib/data/Storage.h +++ b/src/lib/data/Storage.h @@ -21,7 +21,7 @@ public: virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type) = 0; virtual void addComponentAccess(Id edgeId , int type) = 0; virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0; - virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol) = 0; + virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol) = 0; virtual void forEachFile(std::function callback) const = 0; virtual void forEachNode(std::function callback) const = 0; diff --git a/src/lib/data/StorageTypes.h b/src/lib/data/StorageTypes.h index f71c3c26..b6dbbc6e 100644 --- a/src/lib/data/StorageTypes.h +++ b/src/lib/data/StorageTypes.h @@ -171,14 +171,16 @@ struct StorageError StorageError() : message("") , fatal(0) + , indexed(0) , filePath("") , lineNumber(-1) , columnNumber(-1) {} - StorageError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber) + StorageError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber) : message(message) , fatal(fatal) + , indexed(indexed) , filePath(filePath) , lineNumber(lineNumber) , columnNumber(columnNumber) @@ -186,6 +188,7 @@ struct StorageError std::string message; bool fatal; + bool indexed; std::string filePath; uint lineNumber; uint columnNumber; diff --git a/src/lib/data/parser/Parser.h b/src/lib/data/parser/Parser.h index 79b48e14..e1198503 100644 --- a/src/lib/data/parser/Parser.h +++ b/src/lib/data/parser/Parser.h @@ -21,7 +21,9 @@ public: std::vector systemHeaderSearchPaths; std::vector frameworkSearchPaths; std::vector compilerFlags; + bool logErrors; + std::string language; std::string languageStandard; diff --git a/src/lib/data/parser/ParserClient.h b/src/lib/data/parser/ParserClient.h index cc0adf11..de458b2e 100644 --- a/src/lib/data/parser/ParserClient.h +++ b/src/lib/data/parser/ParserClient.h @@ -42,7 +42,7 @@ public: virtual void startParsingFile() = 0; virtual void finishParsingFile() = 0; - virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) = 0; + virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0; virtual void onTypedefParsed( const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit) = 0; diff --git a/src/lib/data/parser/ParserClientImpl.cpp b/src/lib/data/parser/ParserClientImpl.cpp index fe9e0383..455a5e55 100644 --- a/src/lib/data/parser/ParserClientImpl.cpp +++ b/src/lib/data/parser/ParserClientImpl.cpp @@ -34,7 +34,7 @@ void ParserClientImpl::finishParsingFile() { } -void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal) +void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) { log(std::string(fatal ? "FATAL: " : "ERROR: "), message, location); @@ -43,7 +43,7 @@ void ParserClientImpl::onError(const ParseLocation& location, const std::string& return; } - addError(message, fatal, location); + addError(message, fatal, indexed, location); } void ParserClientImpl::onTypedefParsed( @@ -576,14 +576,14 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location) ); } -void ParserClientImpl::addError(const std::string& message, bool fatal, const ParseLocation& location) +void ParserClientImpl::addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location) { if (!m_storage) { return; } - m_storage->addError(message, fatal, location.filePath.str(), location.startLineNumber, location.startColumnNumber); + m_storage->addError(message, fatal, indexed, location.filePath.str(), location.startLineNumber, location.startColumnNumber); } void ParserClientImpl::log(std::string type, std::string str, const ParseLocation& location) const diff --git a/src/lib/data/parser/ParserClientImpl.h b/src/lib/data/parser/ParserClientImpl.h index f4b177da..b587de18 100644 --- a/src/lib/data/parser/ParserClientImpl.h +++ b/src/lib/data/parser/ParserClientImpl.h @@ -21,7 +21,7 @@ public: virtual void startParsingFile(); virtual void finishParsingFile(); - virtual void onError(const ParseLocation& location, const std::string& message, bool fatal); + virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed); virtual void onTypedefParsed( const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit); @@ -97,7 +97,7 @@ private: void addSourceLocation(Id elementId, const ParseLocation& location, int type); void addComponentAccess(Id nodeId , int type); void addCommentLocation(const ParseLocation& location); - void addError(const std::string& message, bool fatal, const ParseLocation& location); + void addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location); void log(std::string type, std::string str, const ParseLocation& location) const; diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 5a86c2a2..b0d7c22d 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -153,6 +153,16 @@ void ApplicationSettings::setIndexerThreadCount(const int count) setValue("application/indexer_thread_count", count); } +bool ApplicationSettings::getShowExternalNonFatalErrors() const +{ + return getValue("application/show_external_non_fatal_errors", false); +} + +void ApplicationSettings::setShowExternalNonFatalErrors(const bool show) +{ + setValue("application/show_external_non_fatal_errors", show); +} + int ApplicationSettings::getWindowBaseWidth() const { return getValue("application/window_base_width", 500); diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index d7cd4e00..d7ec2c79 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -50,6 +50,9 @@ public: int getIndexerThreadCount() const; void setIndexerThreadCount(const int count); + bool getShowExternalNonFatalErrors() const; + void setShowExternalNonFatalErrors(const bool show); + int getWindowBaseWidth() const; int getWindowBaseHeight() const; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index 3d3542eb..29b711c0 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -84,6 +84,21 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int& ); row++; + + // ignore non-fatal errors in non-indexed files + QLabel* errorsLabel = createFormLabel("Non-Fatal Errors"); + + m_fatalErrors = new QCheckBox("Display non-fatal errors in unindexed files", this); + + layout->addWidget(errorsLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_fatalErrors, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); + + addHelpButton( + "When checked non-fatal errors within included unindexed files are also shown." + , layout, row + ); + + row++; } void QtProjectWizzardContentPreferences::load() @@ -96,6 +111,7 @@ void QtProjectWizzardContentPreferences::load() m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1); m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1); + m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors()); } void QtProjectWizzardContentPreferences::save() @@ -108,6 +124,7 @@ void QtProjectWizzardContentPreferences::save() appSettings->setCodeTabWidth(m_tabWidth->currentIndex() + 1); appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1); + appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked()); } bool QtProjectWizzardContentPreferences::check() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h index fc2c4faf..77798b66 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h @@ -1,6 +1,7 @@ #ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H #define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H +#include #include #include @@ -27,6 +28,7 @@ private: QComboBox* m_fontSize; QComboBox* m_tabWidth; QComboBox* m_threads; + QCheckBox* m_fatalErrors; }; #endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H diff --git a/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp b/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp index c4baadd2..bee4dca2 100644 --- a/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp +++ b/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp @@ -4,15 +4,18 @@ #include "data/parser/ParseLocation.h" #include "data/parser/ParserClient.h" +#include "utility/file/FileRegister.h" CxxDiagnosticConsumer::CxxDiagnosticConsumer( clang::raw_ostream &os, clang::DiagnosticOptions *diags, ParserClient* client, + FileRegister* fileRegister, bool useLogging ) : clang::TextDiagnosticPrinter(os, diags) , m_client(client) + , m_register(fileRegister) , m_isParsingFile(false) , m_useLogging(useLogging) { @@ -75,6 +78,11 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev column = presumedLocation.getColumn(); } - m_client->onError(ParseLocation(filePath, line, column), message, (level == clang::DiagnosticsEngine::Fatal)); + m_client->onError( + ParseLocation(filePath, line, column), + message, + level == clang::DiagnosticsEngine::Fatal, + m_register->hasFilePath(filePath) + ); } } diff --git a/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.h b/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.h index bdcbb938..d9259936 100644 --- a/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.h +++ b/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.h @@ -3,6 +3,7 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" +class FileRegister; class ParserClient; class CxxDiagnosticConsumer @@ -13,6 +14,7 @@ public: clang::raw_ostream &os, clang::DiagnosticOptions *diags, ParserClient* client, + FileRegister* fileRegister, bool useLogging = true ); @@ -23,6 +25,8 @@ public: private: ParserClient* m_client; + FileRegister* m_register; + bool m_isParsingFile; bool m_useLogging; }; diff --git a/src/lib_parser/data/parser/cxx/CxxParser.cpp b/src/lib_parser/data/parser/cxx/CxxParser.cpp index e16ce9df..1faa0647 100644 --- a/src/lib_parser/data/parser/cxx/CxxParser.cpp +++ b/src/lib_parser/data/parser/cxx/CxxParser.cpp @@ -183,7 +183,7 @@ std::shared_ptr CxxParser::getDiagnostics(const Arguments { llvm::IntrusiveRefCntPtr options = new clang::DiagnosticOptions(); return std::make_shared( - llvm::errs(), &*options, m_client, arguments.logErrors); + llvm::errs(), &*options, m_client, m_fileRegister.get(), arguments.logErrors); } void CxxParser::setupParsing(const Arguments& arguments) diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index a5315a2f..2b936186 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -2948,7 +2948,7 @@ private: { } - virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) + virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) { errors.push_back(addLocationSuffix(message, location)); }