diff --git a/src/lib/data/parser/ParserClient.h b/src/lib/data/parser/ParserClient.h index 766aebfc..182075f2 100644 --- a/src/lib/data/parser/ParserClient.h +++ b/src/lib/data/parser/ParserClient.h @@ -32,6 +32,8 @@ public: virtual void recordComment(const ParseLocation& location) = 0; virtual void recordError(const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit, const ParseLocation& location) = 0; + + virtual bool hasContent() const = 0; }; #endif // PARSER_CLIENT_H diff --git a/src/lib/data/parser/ParserClientImpl.cpp b/src/lib/data/parser/ParserClientImpl.cpp index 1e32f0e8..6b7fc599 100644 --- a/src/lib/data/parser/ParserClientImpl.cpp +++ b/src/lib/data/parser/ParserClientImpl.cpp @@ -99,6 +99,11 @@ void ParserClientImpl::recordError( } } +bool ParserClientImpl::hasContent() const +{ + return m_storage->getByteSize(1) > 0; +} + NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolKind) const { switch (symbolKind) diff --git a/src/lib/data/parser/ParserClientImpl.h b/src/lib/data/parser/ParserClientImpl.h index 020afc1b..c64452d7 100644 --- a/src/lib/data/parser/ParserClientImpl.h +++ b/src/lib/data/parser/ParserClientImpl.h @@ -31,6 +31,8 @@ public: void recordError(const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit, const ParseLocation& location) override; + bool hasContent() const override; + private: NodeType symbolKindToNodeType(SymbolKind symbolType) const; Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const; diff --git a/src/lib_cxx/data/parser/cxx/CxxParser.cpp b/src/lib_cxx/data/parser/cxx/CxxParser.cpp index bfc1a56a..11421bc9 100644 --- a/src/lib_cxx/data/parser/cxx/CxxParser.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxParser.cpp @@ -17,6 +17,7 @@ #include "FileRegister.h" #include "IndexerCommandCxx.h" #include "logging.h" +#include "ParserClient.h" #include "ResourcePaths.h" #include "TextAccess.h" #include "utilityString.h" @@ -190,10 +191,10 @@ void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase tool.setDiagnosticConsumer(diagnostics.get()); + ClangInvocationInfo info; if (LogManager::getInstance()->getLoggingEnabled()) { - const ClangInvocationInfo info = getClangInvocationString(compilationDatabase); - + info = getClangInvocationString(compilationDatabase); LOG_INFO("Clang Invocation: " + info.invocation.substr(0, ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled() ? std::string::npos : 20000)); if (!info.errors.empty()) @@ -204,6 +205,26 @@ void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase ASTActionFactory actionFactory(m_client, canonicalFilePathCache, m_indexerStateInfo); tool.run(&actionFactory); + + if (!m_client->hasContent()) + { + if (info.invocation.empty()) + { + info = getClangInvocationString(compilationDatabase); + } + + if (!info.errors.empty()) + { + Id fileId = m_client->recordFile(sourceFilePath, true); + m_client->recordError( + L"Clang Invocation errors: " + utility::decodeFromUtf8(info.errors), + true, + true, + sourceFilePath, + ParseLocation(fileId, 1, 1) + ); + } + } } std::vector CxxParser::getCommandlineArgumentsEssential(const std::vector& compilerFlags) const