diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index 89b7e556..d8ab4ffb 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -144,7 +144,7 @@ void TaskBuildIndex::doExit(std::shared_ptr blackboard) is->addError(StorageErrorData( "The translation unit threw an exception during indexing. Please check if the source file " "conforms to the specified language standard and all necessary options are defined within your project " - "setup.", "", path, 1, 1, true, true + "setup.", path, 1, 1, true, true )); LOG_INFO_STREAM(<< "crashed translation unit: " << path.str()); } diff --git a/src/lib/data/indexer/interprocess/shared_types/SharedStorageTypes.h b/src/lib/data/indexer/interprocess/shared_types/SharedStorageTypes.h index abe48218..3a304077 100644 --- a/src/lib/data/indexer/interprocess/shared_types/SharedStorageTypes.h +++ b/src/lib/data/indexer/interprocess/shared_types/SharedStorageTypes.h @@ -117,7 +117,6 @@ struct SharedStorageErrorData { SharedStorageErrorData( const std::string& message, - const std::string& commandline, const std::string& filePath, uint lineNumber, uint columnNumber, @@ -126,7 +125,6 @@ struct SharedStorageErrorData SharedMemory::Allocator* allocator ) : message(message.c_str(), allocator) - , commandline(commandline.c_str(), allocator) , filePath(filePath.c_str(), allocator) , lineNumber(lineNumber) , columnNumber(columnNumber) @@ -135,7 +133,6 @@ struct SharedStorageErrorData {} SharedMemory::String message; - SharedMemory::String commandline; SharedMemory::String filePath; uint lineNumber; @@ -148,14 +145,14 @@ struct SharedStorageErrorData inline SharedStorageErrorData toShared(const StorageErrorData& error, SharedMemory::Allocator* allocator) { return SharedStorageErrorData( - error.message, error.commandline, error.filePath.str(), + error.message, error.filePath.str(), error.lineNumber, error.columnNumber, error.fatal, error.indexed, allocator); } inline StorageErrorData fromShared(const SharedStorageErrorData& error) { return StorageErrorData( - error.message.c_str(), error.commandline.c_str(), FilePath(error.filePath.c_str()), + error.message.c_str(), FilePath(error.filePath.c_str()), error.lineNumber, error.columnNumber, error.fatal, error.indexed); } diff --git a/src/lib/data/parser/ParserClient.cpp b/src/lib/data/parser/ParserClient.cpp index c2f4663d..c75ad7ec 100644 --- a/src/lib/data/parser/ParserClient.cpp +++ b/src/lib/data/parser/ParserClient.cpp @@ -80,9 +80,9 @@ ParserClient::~ParserClient() } void ParserClient::recordError( - const ParseLocation& location, const std::string& message, const std::string& commandline, bool fatal, bool indexed) + const ParseLocation& location, const std::string& message, bool fatal, bool indexed) { - doRecordError(location, message, commandline, fatal, indexed); + doRecordError(location, message, fatal, indexed); if (fatal) { diff --git a/src/lib/data/parser/ParserClient.h b/src/lib/data/parser/ParserClient.h index ff9a568e..1ff98a46 100644 --- a/src/lib/data/parser/ParserClient.h +++ b/src/lib/data/parser/ParserClient.h @@ -49,8 +49,8 @@ public: virtual void recordQualifierLocation( const NameHierarchy& qualifierName, const ParseLocation& location) = 0; - void recordError(const ParseLocation& location, const std::string& message, const std::string& commandline, - bool fatal, bool indexed); + void recordError( + const ParseLocation& location, const std::string& message, bool fatal, bool indexed); virtual void recordLocalSymbol(const std::string& name, const ParseLocation& location) = 0; virtual void recordFile(const FileInfo& fileInfo) = 0; @@ -59,8 +59,8 @@ public: bool hasFatalErrors() const; protected: - virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline, - bool fatal, bool indexed) = 0; + virtual void doRecordError( + const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0; bool m_hasFatalErrors; }; diff --git a/src/lib/data/parser/ParserClientImpl.cpp b/src/lib/data/parser/ParserClientImpl.cpp index 5a93afba..e6abec0c 100644 --- a/src/lib/data/parser/ParserClientImpl.cpp +++ b/src/lib/data/parser/ParserClientImpl.cpp @@ -91,11 +91,11 @@ void ParserClientImpl::recordComment(const ParseLocation& location) } void ParserClientImpl::doRecordError( - const ParseLocation& location, const std::string& message, const std::string& commandline, bool fatal, bool indexed) + const ParseLocation& location, const std::string& message, bool fatal, bool indexed) { if (location.isValid()) { - addError(message, commandline, fatal, indexed, location); + addError(message, fatal, indexed, location); } } @@ -333,7 +333,7 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location) } void ParserClientImpl::addError( - const std::string& message, const std::string& commandline, bool fatal, bool indexed, const ParseLocation& location) + const std::string& message, bool fatal, bool indexed, const ParseLocation& location) { if (!m_storage) { @@ -341,6 +341,6 @@ void ParserClientImpl::addError( } m_storage->addError(StorageErrorData( - message, commandline, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed + message, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed )); } diff --git a/src/lib/data/parser/ParserClientImpl.h b/src/lib/data/parser/ParserClientImpl.h index 8e38b3e3..8e391699 100644 --- a/src/lib/data/parser/ParserClientImpl.h +++ b/src/lib/data/parser/ParserClientImpl.h @@ -44,8 +44,8 @@ public: virtual void recordComment(const ParseLocation& location) override; private: - virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline, - bool fatal, bool indexed) override; + virtual void doRecordError( + const ParseLocation& location, const std::string& message, bool fatal, bool indexed) override; NodeType symbolKindToNodeType(SymbolKind symbolType) const; Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const; @@ -60,7 +60,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, const std::string& commandline, bool fatal, bool indexed, + void addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location); std::shared_ptr m_storage; diff --git a/src/lib/data/storage/IntermediateStorage.cpp b/src/lib/data/storage/IntermediateStorage.cpp index 4e521f0f..60ac93bf 100644 --- a/src/lib/data/storage/IntermediateStorage.cpp +++ b/src/lib/data/storage/IntermediateStorage.cpp @@ -44,7 +44,6 @@ size_t IntermediateStorage::getByteSize(size_t stringSize) const byteSize += sizeof(StorageErrorData); byteSize += stringSize + storageError.filePath.str().size(); byteSize += stringSize + storageError.message.size(); - byteSize += stringSize + storageError.commandline.size(); } for (const StorageNode& storageNode: getStorageNodes()) diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index da907554..e079f1ea 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -269,15 +269,12 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data) if (id == 0) { - const std::string sanitizedCommandline = utility::replace(data.commandline, "'", "''"); - m_insertErrorStmt.bind(1, sanitizedMessage.c_str()); - m_insertErrorStmt.bind(2, sanitizedCommandline.c_str()); - m_insertErrorStmt.bind(3, data.fatal); - m_insertErrorStmt.bind(4, data.indexed); - m_insertErrorStmt.bind(5, data.filePath.str().c_str()); - m_insertErrorStmt.bind(6, int(data.lineNumber)); - m_insertErrorStmt.bind(7, int(data.columnNumber)); + m_insertErrorStmt.bind(2, data.fatal); + m_insertErrorStmt.bind(3, data.indexed); + m_insertErrorStmt.bind(4, data.filePath.str().c_str()); + m_insertErrorStmt.bind(5, int(data.lineNumber)); + m_insertErrorStmt.bind(6, int(data.columnNumber)); const bool success = executeStatement(m_insertErrorStmt); if (success) @@ -954,7 +951,6 @@ void SqliteIndexStorage::setupTables() "CREATE TABLE IF NOT EXISTS error(" "id INTEGER NOT NULL, " "message TEXT, " - "commandline TEXT, " "fatal INTEGER NOT NULL, " "indexed INTEGER NOT NULL, " "file_path TEXT, " @@ -1042,7 +1038,7 @@ void SqliteIndexStorage::setupPrecompiledStatements() "LIMIT 1;" ); m_insertErrorStmt = m_database.compileStatement( - "INSERT INTO error(message, commandline, fatal, indexed, file_path, line_number, column_number) VALUES(?, ?, ?, ?, ?, ?, ?);" + "INSERT INTO error(message, fatal, indexed, file_path, line_number, column_number) VALUES(?, ?, ?, ?, ?, ?);" ); } catch (CppSQLite3Exception& e) @@ -1288,7 +1284,7 @@ template <> std::vector SqliteIndexStorage::doGetAll(const std::string& query) const { CppSQLite3Query q = executeQuery( - "SELECT message, commandline, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";" + "SELECT message, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";" ); std::vector errors; @@ -1296,17 +1292,17 @@ std::vector SqliteIndexStorage::doGetAll(const std:: while (!q.eof()) { const std::string message = q.getStringField(0, ""); - const std::string commandline = q.getStringField(1, ""); - const bool fatal = q.getIntField(2, 0); - const bool indexed = q.getIntField(3, 0); - const std::string filePath = q.getStringField(4, ""); - const int lineNumber = q.getIntField(5, -1); - const int columnNumber = q.getIntField(6, -1); + const bool fatal = q.getIntField(1, 0); + 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( - id, message, commandline, FilePath(filePath), lineNumber, columnNumber, fatal, indexed)); + id, message, FilePath(filePath), lineNumber, columnNumber, fatal, indexed) + ); id++; } diff --git a/src/lib/data/storage/type/StorageError.h b/src/lib/data/storage/type/StorageError.h index 044311e5..788c4db4 100644 --- a/src/lib/data/storage/type/StorageError.h +++ b/src/lib/data/storage/type/StorageError.h @@ -18,7 +18,6 @@ struct StorageErrorData StorageErrorData( const std::string& message, - const std::string& commandline, const FilePath& filePath, uint lineNumber, uint columnNumber, @@ -26,7 +25,6 @@ struct StorageErrorData bool indexed ) : message(message) - , commandline(commandline) , filePath(filePath) , lineNumber(lineNumber) , columnNumber(columnNumber) @@ -35,7 +33,6 @@ struct StorageErrorData {} std::string message; - std::string commandline; FilePath filePath; uint lineNumber; @@ -60,7 +57,6 @@ struct StorageError: public StorageErrorData StorageError( Id id, const std::string& message, - const std::string& commandline, const FilePath& filePath, uint lineNumber, uint columnNumber, @@ -69,7 +65,6 @@ struct StorageError: public StorageErrorData ) : StorageErrorData( message, - commandline, filePath, lineNumber, columnNumber, diff --git a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp index 40a69383..84a7b78a 100644 --- a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp @@ -94,14 +94,8 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev m_client->recordError( location, message, - m_commandline, level == clang::DiagnosticsEngine::Fatal, m_register->hasFilePath(location.filePath) ); } } - -void CxxDiagnosticConsumer::setCommandLine(const std::string& commandline) -{ - m_commandline = commandline; -} diff --git a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h index 5862cbb2..dc9dc442 100644 --- a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h +++ b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h @@ -25,15 +25,11 @@ public: void HandleDiagnostic(clang::DiagnosticsEngine::Level level, const clang::Diagnostic& info); - void setCommandLine(const std::string& commandline); - private: std::shared_ptr m_client; std::shared_ptr m_register; std::shared_ptr m_canonicalFilePathCache; - std::string m_commandline; - bool m_isParsingFile; bool m_useLogging; }; diff --git a/src/lib_cxx/data/parser/cxx/CxxParser.cpp b/src/lib_cxx/data/parser/cxx/CxxParser.cpp index e88c865a..6f866fb5 100644 --- a/src/lib_cxx/data/parser/cxx/CxxParser.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxParser.cpp @@ -116,17 +116,6 @@ void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase std::shared_ptr diagnostics = getDiagnostics(canonicalFilePathCache, true); - std::vector compileCommands = compilationDatabase->getCompileCommands(sourceFilePath.str()); - if (compileCommands.size() == 1) - { - std::string commandline; - for (const std::string& str : compileCommands[0].CommandLine) - { - commandline += str + " "; - } - diagnostics->setCommandLine(commandline); - } - tool.setDiagnosticConsumer(diagnostics.get()); ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache); diff --git a/src/lib_gui/qt/view/QtErrorView.cpp b/src/lib_gui/qt/view/QtErrorView.cpp index ee1ce66d..cc43a392 100644 --- a/src/lib_gui/qt/view/QtErrorView.cpp +++ b/src/lib_gui/qt/view/QtErrorView.cpp @@ -76,16 +76,15 @@ void QtErrorView::initView() m_table->setItemDelegate(new SelectableDelegate()); // Setup Table Headers - m_model->setColumnCount(7); + m_model->setColumnCount(COLUMN_MAX + 1); m_table->setColumnWidth(COLUMN::TYPE, 80); m_table->setColumnWidth(COLUMN::MESSAGE, 450); m_table->setColumnWidth(COLUMN::FILE, 300); m_table->setColumnWidth(COLUMN::LINE, 50); - m_table->setColumnWidth(COLUMN::COMMANDLINE, 120); m_table->setColumnHidden(COLUMN::ID, true); QStringList headers; - headers << "Type" << "Message" << "File" << "Line" << "Command Line" << "Indexed"; + headers << "Type" << "Message" << "File" << "Line" << "Indexed"; m_model->setHorizontalHeaderLabels(headers); connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, @@ -331,7 +330,6 @@ void QtErrorView::addErrorToTable(const ErrorInfo& error) m_model->item(rowNumber, COLUMN::FILE)->setToolTip(error.filePath.str().c_str()); m_model->setItem(rowNumber, COLUMN::LINE, new QStandardItem(QString::number(error.lineNumber))); - m_model->setItem(rowNumber, COLUMN::COMMANDLINE, new QStandardItem(error.commandline.c_str())); m_model->setItem(rowNumber, COLUMN::INDEXED, new QStandardItem(error.indexed ? "yes" : "no")); diff --git a/src/lib_gui/qt/view/QtErrorView.h b/src/lib_gui/qt/view/QtErrorView.h index 2a7ec485..97abd806 100644 --- a/src/lib_gui/qt/view/QtErrorView.h +++ b/src/lib_gui/qt/view/QtErrorView.h @@ -50,9 +50,9 @@ private: MESSAGE = 1, FILE = 2, LINE = 3, - COMMANDLINE = 4, - INDEXED = 5, - ID = 6 + INDEXED = 4, + ID = 5, + COLUMN_MAX = ID }; void setStyleSheet() const; diff --git a/src/lib_java/data/parser/java/JavaParser.cpp b/src/lib_java/data/parser/java/JavaParser.cpp index 5b65402f..dc6c3035 100644 --- a/src/lib_java/data/parser/java/JavaParser.cpp +++ b/src/lib_java/data/parser/java/JavaParser.cpp @@ -264,8 +264,7 @@ void JavaParser::doRecordError( m_client->recordError( ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn), m_javaEnvironment->toStdString(jMessage), - "", - fatal, indexed + fatal, + indexed ); } - diff --git a/src/test/helper/DumpParserClient.h b/src/test/helper/DumpParserClient.h index e9879cc6..93d9b8b7 100644 --- a/src/test/helper/DumpParserClient.h +++ b/src/test/helper/DumpParserClient.h @@ -82,7 +82,7 @@ public: std::string m_lines; private: - virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline, + virtual void doRecordError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) override { recordLine("ERROR: " + addLocationSuffix(message + " [" + location.filePath.fileName(), location) + "]\n"); diff --git a/src/test/helper/TestParserClient.h b/src/test/helper/TestParserClient.h index dc8e42e0..07f040be 100644 --- a/src/test/helper/TestParserClient.h +++ b/src/test/helper/TestParserClient.h @@ -162,8 +162,11 @@ public: std::vector imports; private: - virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline, - bool fatal, bool indexed) override + virtual void doRecordError( + const ParseLocation& location, + const std::string& message, + bool fatal, + bool indexed) override { errors.push_back(addLocationSuffix(message, location)); }