[PATCH] D118150: [clang] Fix serialized diagnostics edge-cases
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 26 02:22:51 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG76cb4cd074a6: [clang] Fix serialized diagnostics edge-cases (authored by jansvoboda11).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118150/new/
https://reviews.llvm.org/D118150
Files:
clang/lib/Frontend/CompilerInstance.cpp
clang/test/Misc/serialized-diags-emit-header-module-misconfig.c
clang/test/Misc/serialized-diags-unknown-argument.c
clang/test/Misc/serialized-diags-unknown-target.c
clang/tools/driver/cc1_main.cpp
Index: clang/tools/driver/cc1_main.cpp
===================================================================
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -237,8 +237,10 @@
static_cast<void*>(&Clang->getDiagnostics()));
DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics());
- if (!Success)
+ if (!Success) {
+ Clang->getDiagnosticClient().finish();
return 1;
+ }
// Execute the frontend actions.
{
Index: clang/test/Misc/serialized-diags-unknown-target.c
===================================================================
--- /dev/null
+++ clang/test/Misc/serialized-diags-unknown-target.c
@@ -0,0 +1,4 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: not %clang_cc1 %s -triple blah-unknown-unknown -serialize-diagnostic-file %t/diag -o /dev/null 2>&1 | FileCheck %s
+
+// CHECK: error: unknown target triple 'blah-unknown-unknown', please use -triple or -arch
Index: clang/test/Misc/serialized-diags-unknown-argument.c
===================================================================
--- /dev/null
+++ clang/test/Misc/serialized-diags-unknown-argument.c
@@ -0,0 +1,4 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: not %clang_cc1 %s -unknown-argument -serialize-diagnostic-file %t/diag -o /dev/null 2>&1 | FileCheck %s
+
+// CHECK: error: unknown argument: '-unknown-argument'
Index: clang/test/Misc/serialized-diags-emit-header-module-misconfig.c
===================================================================
--- /dev/null
+++ clang/test/Misc/serialized-diags-emit-header-module-misconfig.c
@@ -0,0 +1,4 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: not %clang_cc1 -emit-header-module %s -o %t/out.pcm -serialize-diagnostic-file %t/diag 2>&1 | FileCheck %s
+
+// CHECK: error: header module compilation requires '-fmodules', '-std=c++20', or '-fmodules-ts'
Index: clang/lib/Frontend/CompilerInstance.cpp
===================================================================
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -37,6 +37,7 @@
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Serialization/InMemoryModuleCache.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CrashRecoveryContext.h"
@@ -996,6 +997,11 @@
// DesiredStackSpace available.
noteBottomOfStack();
+ auto FinishDiagnosticClient = llvm::make_scope_exit([&]() {
+ // Notify the diagnostic client that all files were processed.
+ getDiagnosticClient().finish();
+ });
+
raw_ostream &OS = getVerboseOutputStream();
if (!Act.PrepareToExecute(*this))
@@ -1034,9 +1040,6 @@
}
}
- // Notify the diagnostic client that all files were processed.
- getDiagnostics().getClient()->finish();
-
if (getDiagnosticOpts().ShowCarets) {
// We can have multiple diagnostics sharing one diagnostic client.
// Get the total number of warnings/errors from the client.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118150.403183.patch
Type: text/x-patch
Size: 3037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220126/eb84a681/attachment.bin>
More information about the cfe-commits
mailing list