Skip to content

Commit f887854

Browse files
committed
Improve file doesnt exist error with -fbasic-block-sections=
With -fbasicblock-sections=, let the front-end handle the case where the file doesnt exist. The driver only checks if the option syntax is right. Differential Revision: https://reviews.llvm.org/D89500
1 parent 1d78e21 commit f887854

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4924,7 +4924,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
49244924
if (Triple.isX86() && Triple.isOSBinFormatELF()) {
49254925
StringRef Val = A->getValue();
49264926
if (Val != "all" && Val != "labels" && Val != "none" &&
4927-
!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5))))
4927+
!Val.startswith("list="))
49284928
D.Diag(diag::err_drv_invalid_value)
49294929
<< A->getAsString(Args) << A->getValue();
49304930
else

clang/test/CodeGen/basic-block-sections.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_ALL
77
// RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=list=%S/Inputs/basic-block-sections.funcnames -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST
88
// RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all -funique-basic-block-section-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
9+
// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
910

1011
int world(int a) {
1112
if (a > 10)
@@ -38,3 +39,4 @@ int another(int a) {
3839
//
3940
// UNIQUE: .section .text.world.world.1,
4041
// UNIQUE: .section .text.another.another.1,
42+
// ERROR: error: unable to load basic block sections function list: 'No such file or directory'

clang/test/Driver/fbasic-block-sections.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
// RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
55
// RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
66
// RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
7+
// RUN: %clang -### -target x86_64 -fbasic-block-sections=alll %s -S 2>&1 | FileCheck -check-prefix=CHECK-INVALID-VALUE %s
8+
// RUN: %clang -### -target x86_64 -fbasic-block-sections=list %s -S 2>&1 | FileCheck -check-prefix=CHECK-INVALID-VALUE %s
9+
// RUN: %clang -### -target x86_64 -fbasic-block-sections=list= %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NULL-LIST %s
710
//
811
// CHECK-OPT-NONE: "-fbasic-block-sections=none"
912
// CHECK-OPT-ALL: "-fbasic-block-sections=all"
1013
// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
1114
// CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
1215
// CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' for target
16+
// CHECK-INVALID-VALUE: error: invalid value {{[^ ]*}} in '-fbasic-block-sections={{.*}}'
17+
// CHECK-OPT-NULL-LIST: "-fbasic-block-sections=list="

0 commit comments

Comments
 (0)