r363067 - [libclang] Allow skipping warnings from all included files
Nikolai Kosjar via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 11 07:14:25 PDT 2019
Author: nik
Date: Tue Jun 11 07:14:24 2019
New Revision: 363067
URL: http://llvm.org/viewvc/llvm-project?rev=363067&view=rev
Log:
[libclang] Allow skipping warnings from all included files
Depending on the included files and the used warning flags, e.g. -
Weverything, a huge number of warnings can be reported for included
files. As processing that many diagnostics comes with a performance
impact and not all clients are interested in those diagnostics, add a
flag to skip them.
Differential Revision: https://reviews.llvm.org/D48116
Added:
cfe/trunk/test/Index/ignore-warnings-from-headers.cpp
cfe/trunk/test/Index/ignore-warnings-from-headers.h
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/Frontend/ASTUnitTest.cpp
cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jun 11 07:14:24 2019
@@ -32,7 +32,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 58
+#define CINDEX_VERSION_MINOR 59
#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
@@ -1346,7 +1346,17 @@ enum CXTranslationUnit_Flags {
/**
* Used to indicate that implicit attributes should be visited.
*/
- CXTranslationUnit_VisitImplicitAttributes = 0x2000
+ CXTranslationUnit_VisitImplicitAttributes = 0x2000,
+
+ /**
+ * Used to indicate that non-errors from included files should be ignored.
+ *
+ * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
+ * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
+ * the case where these warnings are not of interest, as for an IDE for
+ * example, which typically shows only the diagnostics in the main file.
+ */
+ CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000
};
/**
Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Jun 11 07:14:24 2019
@@ -82,6 +82,9 @@ class TargetInfo;
/// \brief Enumerates the available scopes for skipping function bodies.
enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
+/// \brief Enumerates the available kinds for capturing diagnostics.
+enum class CaptureDiagsKind { None, All, AllWithoutNonErrorsFromIncludes };
+
/// Utility class for loading a ASTContext from an AST file.
class ASTUnit {
public:
@@ -144,7 +147,7 @@ private:
bool OnlyLocalDecls = false;
/// Whether to capture any diagnostics produced.
- bool CaptureDiagnostics = false;
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None;
/// Track whether the main file was loaded from an AST or not.
bool MainFileIsAST;
@@ -250,7 +253,7 @@ private:
bool UserFilesAreVolatile : 1;
static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
- ASTUnit &AST, bool CaptureDiagnostics);
+ ASTUnit &AST, CaptureDiagsKind CaptureDiagnostics);
void TranslateStoredDiagnostics(FileManager &FileMgr,
SourceManager &SrcMan,
@@ -661,8 +664,8 @@ public:
/// Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
static std::unique_ptr<ASTUnit>
create(std::shared_ptr<CompilerInvocation> CI,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool CaptureDiagnostics,
- bool UserFilesAreVolatile);
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+ CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile);
enum WhatToLoad {
/// Load options and the preprocessor state.
@@ -690,7 +693,8 @@ public:
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false,
bool OnlyLocalDecls = false, ArrayRef<RemappedFile> RemappedFiles = None,
- bool CaptureDiagnostics = false, bool AllowPCHWithCompilerErrors = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
+ bool AllowPCHWithCompilerErrors = false,
bool UserFilesAreVolatile = false);
private:
@@ -748,7 +752,8 @@ public:
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
bool Persistent = true, StringRef ResourceFilesPath = StringRef(),
- bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
+ bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
unsigned PrecompilePreambleAfterNParses = 0,
bool CacheCodeCompletionResults = false,
bool IncludeBriefCommentsInCodeCompletion = false,
@@ -773,7 +778,8 @@ public:
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
- bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
+ bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
unsigned PrecompilePreambleAfterNParses = 0,
TranslationUnitKind TUKind = TU_Complete,
bool CacheCodeCompletionResults = false,
@@ -813,7 +819,8 @@ public:
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
- bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
+ bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
ArrayRef<RemappedFile> RemappedFiles = None,
bool RemappedFilesKeepOriginalName = true,
unsigned PrecompilePreambleAfterNParses = 0,
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Jun 11 07:14:24 2019
@@ -608,17 +608,20 @@ private:
};
/// Diagnostic consumer that saves each diagnostic it is given.
-class StoredDiagnosticConsumer : public DiagnosticConsumer {
+class FilterAndStoreDiagnosticConsumer : public DiagnosticConsumer {
SmallVectorImpl<StoredDiagnostic> *StoredDiags;
SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags;
+ bool CaptureNonErrorsFromIncludes = true;
const LangOptions *LangOpts = nullptr;
SourceManager *SourceMgr = nullptr;
public:
- StoredDiagnosticConsumer(
+ FilterAndStoreDiagnosticConsumer(
SmallVectorImpl<StoredDiagnostic> *StoredDiags,
- SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags)
- : StoredDiags(StoredDiags), StandaloneDiags(StandaloneDiags) {
+ SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags,
+ bool CaptureNonErrorsFromIncludes)
+ : StoredDiags(StoredDiags), StandaloneDiags(StandaloneDiags),
+ CaptureNonErrorsFromIncludes(CaptureNonErrorsFromIncludes) {
assert((StoredDiags || StandaloneDiags) &&
"No output collections were passed to StoredDiagnosticConsumer.");
}
@@ -634,21 +637,25 @@ public:
const Diagnostic &Info) override;
};
-/// RAII object that optionally captures diagnostics, if
+/// RAII object that optionally captures and filters diagnostics, if
/// there is no diagnostic client to capture them already.
class CaptureDroppedDiagnostics {
DiagnosticsEngine &Diags;
- StoredDiagnosticConsumer Client;
+ FilterAndStoreDiagnosticConsumer Client;
DiagnosticConsumer *PreviousClient = nullptr;
std::unique_ptr<DiagnosticConsumer> OwningPreviousClient;
public:
CaptureDroppedDiagnostics(
- bool RequestCapture, DiagnosticsEngine &Diags,
+ CaptureDiagsKind CaptureDiagnostics, DiagnosticsEngine &Diags,
SmallVectorImpl<StoredDiagnostic> *StoredDiags,
SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags)
- : Diags(Diags), Client(StoredDiags, StandaloneDiags) {
- if (RequestCapture || Diags.getClient() == nullptr) {
+ : Diags(Diags),
+ Client(StoredDiags, StandaloneDiags,
+ CaptureDiagnostics !=
+ CaptureDiagsKind::AllWithoutNonErrorsFromIncludes) {
+ if (CaptureDiagnostics != CaptureDiagsKind::None ||
+ Diags.getClient() == nullptr) {
OwningPreviousClient = Diags.takeClient();
PreviousClient = Diags.getClient();
Diags.setClient(&Client, false);
@@ -667,8 +674,16 @@ static ASTUnit::StandaloneDiagnostic
makeStandaloneDiagnostic(const LangOptions &LangOpts,
const StoredDiagnostic &InDiag);
-void StoredDiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level Level,
- const Diagnostic &Info) {
+static bool isInMainFile(const clang::Diagnostic &D) {
+ if (!D.hasSourceManager() || !D.getLocation().isValid())
+ return false;
+
+ auto &M = D.getSourceManager();
+ return M.isWrittenInMainFile(M.getExpansionLoc(D.getLocation()));
+}
+
+void FilterAndStoreDiagnosticConsumer::HandleDiagnostic(
+ DiagnosticsEngine::Level Level, const Diagnostic &Info) {
// Default implementation (Warnings/errors count).
DiagnosticConsumer::HandleDiagnostic(Level, Info);
@@ -676,6 +691,11 @@ void StoredDiagnosticConsumer::HandleDia
// about. This effectively drops diagnostics from modules we're building.
// FIXME: In the long run, ee don't want to drop source managers from modules.
if (!Info.hasSourceManager() || &Info.getSourceManager() == SourceMgr) {
+ if (!CaptureNonErrorsFromIncludes && Level <= DiagnosticsEngine::Warning &&
+ !isInMainFile(Info)) {
+ return;
+ }
+
StoredDiagnostic *ResultDiag = nullptr;
if (StoredDiags) {
StoredDiags->emplace_back(Level, Info);
@@ -723,10 +743,13 @@ ASTUnit::getBufferForFile(StringRef File
/// Configure the diagnostics object for use with ASTUnit.
void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
- ASTUnit &AST, bool CaptureDiagnostics) {
+ ASTUnit &AST,
+ CaptureDiagsKind CaptureDiagnostics) {
assert(Diags.get() && "no DiagnosticsEngine was provided");
- if (CaptureDiagnostics)
- Diags->setClient(new StoredDiagnosticConsumer(&AST.StoredDiagnostics, nullptr));
+ if (CaptureDiagnostics != CaptureDiagsKind::None)
+ Diags->setClient(new FilterAndStoreDiagnosticConsumer(
+ &AST.StoredDiagnostics, nullptr,
+ CaptureDiagnostics != CaptureDiagsKind::AllWithoutNonErrorsFromIncludes));
}
std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
@@ -734,7 +757,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, bool UseDebugInfo,
bool OnlyLocalDecls, ArrayRef<RemappedFile> RemappedFiles,
- bool CaptureDiagnostics, bool AllowPCHWithCompilerErrors,
+ CaptureDiagsKind CaptureDiagnostics, bool AllowPCHWithCompilerErrors,
bool UserFilesAreVolatile) {
std::unique_ptr<ASTUnit> AST(new ASTUnit(true));
@@ -1336,8 +1359,8 @@ ASTUnit::getMainBufferWithPrecompiledPre
ASTUnitPreambleCallbacks Callbacks;
{
llvm::Optional<CaptureDroppedDiagnostics> Capture;
- if (CaptureDiagnostics)
- Capture.emplace(/*RequestCapture=*/true, *Diagnostics, &NewPreambleDiags,
+ if (CaptureDiagnostics != CaptureDiagsKind::None)
+ Capture.emplace(CaptureDiagnostics, *Diagnostics, &NewPreambleDiags,
&NewPreambleDiagsStandalone);
// We did not previously compute a preamble, or it can't be reused anyway.
@@ -1465,7 +1488,8 @@ StringRef ASTUnit::getASTFileName() cons
std::unique_ptr<ASTUnit>
ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
- bool CaptureDiagnostics, bool UserFilesAreVolatile) {
+ CaptureDiagsKind CaptureDiagnostics,
+ bool UserFilesAreVolatile) {
std::unique_ptr<ASTUnit> AST(new ASTUnit(false));
ConfigureDiags(Diags, *AST, CaptureDiagnostics);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
@@ -1487,7 +1511,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvoca
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FrontendAction *Action,
ASTUnit *Unit, bool Persistent, StringRef ResourceFilesPath,
- bool OnlyLocalDecls, bool CaptureDiagnostics,
+ bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
unsigned PrecompilePreambleAfterNParses, bool CacheCodeCompletionResults,
bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile,
std::unique_ptr<ASTUnit> *ErrAST) {
@@ -1665,7 +1689,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
- bool OnlyLocalDecls, bool CaptureDiagnostics,
+ bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
bool UserFilesAreVolatile) {
@@ -1702,7 +1726,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
- bool OnlyLocalDecls, bool CaptureDiagnostics,
+ bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
ArrayRef<RemappedFile> RemappedFiles, bool RemappedFilesKeepOriginalName,
unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
@@ -2159,7 +2183,7 @@ void ASTUnit::CodeComplete(
// Set up diagnostics, capturing any diagnostics produced.
Clang->setDiagnostics(&Diag);
- CaptureDroppedDiagnostics Capture(true,
+ CaptureDroppedDiagnostics Capture(CaptureDiagsKind::All,
Clang->getDiagnostics(),
&StoredDiagnostics, nullptr);
ProcessWarningOptions(Diag, Inv.getDiagnosticOpts());
Added: cfe/trunk/test/Index/ignore-warnings-from-headers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ignore-warnings-from-headers.cpp?rev=363067&view=auto
==============================================================================
--- cfe/trunk/test/Index/ignore-warnings-from-headers.cpp (added)
+++ cfe/trunk/test/Index/ignore-warnings-from-headers.cpp Tue Jun 11 07:14:24 2019
@@ -0,0 +1,7 @@
+#include "ignore-warnings-from-headers.h"
+
+void g(int unusedInMainFile) {}
+
+// RUN: env CINDEXTEST_IGNORE_NONERRORS_FROM_INCLUDED_FILES=1 c-index-test -test-load-source function %s -Wunused-parameter 2>&1 | FileCheck %s
+// CHECK-NOT: warning: unused parameter 'unusedInHeader'
+// CHECK: warning: unused parameter 'unusedInMainFile'
Added: cfe/trunk/test/Index/ignore-warnings-from-headers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ignore-warnings-from-headers.h?rev=363067&view=auto
==============================================================================
--- cfe/trunk/test/Index/ignore-warnings-from-headers.h (added)
+++ cfe/trunk/test/Index/ignore-warnings-from-headers.h Tue Jun 11 07:14:24 2019
@@ -0,0 +1 @@
+void f(int unusedInHeader) {}
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Jun 11 07:14:24 2019
@@ -88,6 +88,8 @@ static unsigned getDefaultParsingOptions
options |= CXTranslationUnit_IncludeAttributedTypes;
if (getenv("CINDEXTEST_VISIT_IMPLICIT_ATTRIBUTES"))
options |= CXTranslationUnit_VisitImplicitAttributes;
+ if (getenv("CINDEXTEST_IGNORE_NONERRORS_FROM_INCLUDED_FILES"))
+ options |= CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles;
return options;
}
Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Tue Jun 11 07:14:24 2019
@@ -264,7 +264,7 @@ static bool printSourceSymbolsFromModule
modulePath, *pchRdr, ASTUnit::LoadASTOnly, Diags,
FileSystemOpts, /*UseDebugInfo=*/false,
/*OnlyLocalDecls=*/true, None,
- /*CaptureDiagnostics=*/false,
+ CaptureDiagsKind::None,
/*AllowPCHWithCompilerErrors=*/true,
/*UserFilesAreVolatile=*/false);
if (!AU) {
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jun 11 07:14:24 2019
@@ -3356,7 +3356,7 @@ enum CXErrorCode clang_createTranslation
ASTUnit::LoadEverything, Diags,
FileSystemOpts, /*UseDebugInfo=*/false,
CXXIdx->getOnlyLocalDecls(), None,
- /*CaptureDiagnostics=*/true,
+ CaptureDiagsKind::All,
/*AllowPCHWithCompilerErrors=*/true,
/*UserFilesAreVolatile=*/true);
*out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
@@ -3429,6 +3429,10 @@ clang_parseTranslationUnit_Impl(CXIndex
if (options & CXTranslationUnit_KeepGoing)
Diags->setFatalsAsError(true);
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::All;
+ if (options & CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles)
+ CaptureDiagnostics = CaptureDiagsKind::AllWithoutNonErrorsFromIncludes;
+
// Recover resources if we crash before exiting this function.
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> >
@@ -3506,7 +3510,7 @@ clang_parseTranslationUnit_Impl(CXIndex
Args->data(), Args->data() + Args->size(),
CXXIdx->getPCHContainerOperations(), Diags,
CXXIdx->getClangResourcesPath(), CXXIdx->getOnlyLocalDecls(),
- /*CaptureDiagnostics=*/true, *RemappedFiles.get(),
+ CaptureDiagnostics, *RemappedFiles.get(),
/*RemappedFilesKeepOriginalName=*/true, PrecompilePreambleAfterNParses,
TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
/*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Tue Jun 11 07:14:24 2019
@@ -443,10 +443,14 @@ static CXErrorCode clang_indexSourceFile
if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForIndexing))
setThreadBackgroundPriority();
- bool CaptureDiagnostics = !Logger::isLoggingEnabled();
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::All;
+ if (TU_options & CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles)
+ CaptureDiagnostics = CaptureDiagsKind::AllWithoutNonErrorsFromIncludes;
+ if (Logger::isLoggingEnabled())
+ CaptureDiagnostics = CaptureDiagsKind::None;
CaptureDiagnosticConsumer *CaptureDiag = nullptr;
- if (CaptureDiagnostics)
+ if (CaptureDiagnostics != CaptureDiagsKind::None)
CaptureDiag = new CaptureDiagnosticConsumer();
// Configure the diagnostics.
Modified: cfe/trunk/unittests/Frontend/ASTUnitTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/ASTUnitTest.cpp?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/unittests/Frontend/ASTUnitTest.cpp (original)
+++ cfe/trunk/unittests/Frontend/ASTUnitTest.cpp Tue Jun 11 07:14:24 2019
@@ -51,8 +51,8 @@ protected:
PCHContainerOps = std::make_shared<PCHContainerOperations>();
return ASTUnit::LoadFromCompilerInvocation(
- CInvok, PCHContainerOps, Diags, FileMgr, false, false, 0, TU_Complete,
- false, false, isVolatile);
+ CInvok, PCHContainerOps, Diags, FileMgr, false, CaptureDiagsKind::None,
+ 0, TU_Complete, false, false, isVolatile);
}
};
Modified: cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp?rev=363067&r1=363066&r2=363067&view=diff
==============================================================================
--- cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp (original)
+++ cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp Tue Jun 11 07:14:24 2019
@@ -96,8 +96,8 @@ public:
FileManager *FileMgr = new FileManager(FSOpts, VFS);
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCompilerInvocation(
- CI, PCHContainerOpts, Diags, FileMgr, false, false,
- /*PrecompilePreambleAfterNParses=*/1);
+ CI, PCHContainerOpts, Diags, FileMgr, false, CaptureDiagsKind::None,
+ /*PrecompilePreambleAfterNParses=*/1);
return AST;
}
More information about the cfe-commits
mailing list