Remove no longer applied patch files
This commit is contained in:
parent
56d54b9e15
commit
1d5bee47d5
@ -1,47 +0,0 @@
|
||||
From ad7211df6f257e39da2e5a11b2456b4488f32a1e Mon Sep 17 00:00:00 2001
|
||||
From: Oliver Bruns <obruns@gmail.com>
|
||||
Date: Mon, 6 Apr 2020 10:38:30 +0200
|
||||
Subject: [PATCH] [clang] fix undefined behaviour in
|
||||
RawComment::getFormattedText()
|
||||
|
||||
Summary:
|
||||
Calling `back()` and `pop_back()` on the empty string is undefined
|
||||
behavior [1,2].
|
||||
|
||||
The issue manifested itself as an uncaught `std::out_of_range` exception
|
||||
when running `clangd` compiled on RHEL7 using devtoolset-9.
|
||||
|
||||
[1] https://en.cppreference.com/w/cpp/string/basic_string/back
|
||||
[2] https://en.cppreference.com/w/cpp/string/basic_string/pop_back
|
||||
|
||||
Fixes: 1ff7c32fc91c607b690d4bb9cf42f406be8dde68
|
||||
|
||||
Reviewers: teemperor, ioeric, cfe-commits
|
||||
|
||||
Reviewed By: teemperor
|
||||
|
||||
Subscribers: ilya-biryukov, kadircet, usaxena95
|
||||
|
||||
Tags: #clang
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D77468
|
||||
---
|
||||
clang/lib/AST/RawCommentList.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
|
||||
index 8552b4fcd2b..a8d15036cab 100644
|
||||
--- a/clang/lib/AST/RawCommentList.cpp
|
||||
+++ b/clang/lib/AST/RawCommentList.cpp
|
||||
@@ -431,7 +431,7 @@ std::string RawComment::getFormattedText(const SourceManager &SourceMgr,
|
||||
};
|
||||
|
||||
auto DropTrailingNewLines = [](std::string &Str) {
|
||||
- while (Str.back() == '\n')
|
||||
+ while (!Str.empty() && Str.back() == '\n')
|
||||
Str.pop_back();
|
||||
};
|
||||
|
||||
--
|
||||
2.25.2
|
||||
|
@ -1,99 +0,0 @@
|
||||
From 11857d49948b845dcfd7c7f78595095e3add012d Mon Sep 17 00:00:00 2001
|
||||
From: Rong Xu <xur@google.com>
|
||||
Date: Tue, 25 Feb 2020 08:04:01 -0800
|
||||
Subject: [PATCH] [remark][diagnostics] [codegen] Fix PR44896
|
||||
|
||||
This patch fixes PR44896. For IR input files, option fdiscard-value-names
|
||||
should be ignored as we need named values in loadModule().
|
||||
Commit 60d3947922 sets this option after loadModule() where valued names
|
||||
already created. This creates an inconsistent state in setNameImpl()
|
||||
that leads to a seg fault.
|
||||
This patch forces fdiscard-value-names to be false for IR input files.
|
||||
|
||||
This patch also emits a warning of "ignoring -fdiscard-value-names" if
|
||||
option fdiscard-value-names is explictly enabled in the commandline for
|
||||
IR input files.
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D74878
|
||||
---
|
||||
clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
|
||||
clang/lib/CodeGen/CodeGenAction.cpp | 3 +++
|
||||
clang/lib/Driver/ToolChains/Clang.cpp | 10 +++++++++-
|
||||
clang/test/CodeGen/PR44896.ll | 15 +++++++++++++++
|
||||
4 files changed, 30 insertions(+), 1 deletion(-)
|
||||
create mode 100644 clang/test/CodeGen/PR44896.ll
|
||||
|
||||
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
index ecd871e..48ece91 100644
|
||||
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
@@ -271,6 +271,9 @@ def warn_drv_unsupported_debug_info_opt_for_target : Warning<
|
||||
InGroup<UnsupportedTargetOpt>;
|
||||
def warn_c_kext : Warning<
|
||||
"ignoring -fapple-kext which is valid for C++ and Objective-C++ only">;
|
||||
+def warn_ignoring_fdiscard_for_bitcode : Warning<
|
||||
+ "ignoring -fdiscard-value-names for LLVM Bitcode">,
|
||||
+ InGroup<UnusedCommandLineArgument>;
|
||||
def warn_drv_input_file_unused : Warning<
|
||||
"%0: '%1' input unused%select{ when '%3' is present|}2">,
|
||||
InGroup<UnusedCommandLineArgument>;
|
||||
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
|
||||
index 5ebc34c..81946b1 100644
|
||||
--- a/clang/lib/CodeGen/CodeGenAction.cpp
|
||||
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
|
||||
@@ -1146,6 +1146,9 @@ void CodeGenAction::ExecuteAction() {
|
||||
CI.getTargetOpts(), CI.getLangOpts(),
|
||||
CI.getFrontendOpts().ShowTimers,
|
||||
std::move(LinkModules), *VMContext, nullptr);
|
||||
+ // PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
|
||||
+ // true here because the valued names are needed for reading textual IR.
|
||||
+ Ctx.setDiscardValueNames(false);
|
||||
Ctx.setDiagnosticHandler(
|
||||
std::make_unique<ClangDiagnosticHandler>(CodeGenOpts, &Result));
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
index 19a23c9..d387a1d 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
@@ -4332,8 +4332,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
|
||||
// Discard value names in assert builds unless otherwise specified.
|
||||
if (Args.hasFlag(options::OPT_fdiscard_value_names,
|
||||
- options::OPT_fno_discard_value_names, !IsAssertBuild))
|
||||
+ options::OPT_fno_discard_value_names, !IsAssertBuild)) {
|
||||
+ if (Args.hasArg(options::OPT_fdiscard_value_names) &&
|
||||
+ (std::any_of(Inputs.begin(), Inputs.end(),
|
||||
+ [](const clang::driver::InputInfo &II) {
|
||||
+ return types::isLLVMIR(II.getType());
|
||||
+ }))) {
|
||||
+ D.Diag(diag::warn_ignoring_fdiscard_for_bitcode);
|
||||
+ }
|
||||
CmdArgs.push_back("-discard-value-names");
|
||||
+ }
|
||||
|
||||
// Set the main file name, so that debug info works even with
|
||||
// -save-temps.
|
||||
diff --git a/clang/test/CodeGen/PR44896.ll b/clang/test/CodeGen/PR44896.ll
|
||||
new file mode 100644
|
||||
index 0000000..a4d3445
|
||||
--- /dev/null
|
||||
+++ b/clang/test/CodeGen/PR44896.ll
|
||||
@@ -0,0 +1,15 @@
|
||||
+; RUN: %clang -fdiscard-value-names -S %s -o /dev/null 2>&1 | FileCheck --check-prefix=WARNING %s
|
||||
+; RUN: %clang -S %s -o /dev/null 2>&1 | FileCheck --check-prefix=NOWARNING %s
|
||||
+; RUN: %clang_cc1 -S -emit-llvm %s -discard-value-names -o /dev/null
|
||||
+; PR 44896
|
||||
+
|
||||
+; WARNING: ignoring -fdiscard-value-names for LLVM Bitcode
|
||||
+; NOWARNING-NOT: ignoring -fdiscard-value-names for LLVM Bitcode
|
||||
+
|
||||
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
+target triple = "x86_64--linux-gnu"
|
||||
+
|
||||
+define linkonce i8* @b(i8* %a) {
|
||||
+ ret i8* %a
|
||||
+}
|
||||
+
|
||||
--
|
||||
1.8.3.1
|
||||
|
Loading…
Reference in New Issue
Block a user