Skip to content

Commit 343cecc

Browse files
committed
Address comments
Created using spr 1.3.5
2 parents b32a441 + b17f607 commit 343cecc

File tree

60 files changed

+3509
-5009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3509
-5009
lines changed

clang-tools-extra/test/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ set(CLANG_TOOLS_TEST_DEPS
5050
clang-resource-headers
5151

5252
clang-tidy
53-
# Clang-tidy tests need clang for building modules.
54-
clang
5553
)
5654

5755
# Add lit test dependencies.

clang/docs/InternalsManual.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ wording a diagnostic.
160160
named in a diagnostic message. e.g., prefer wording like ``'this' pointer
161161
cannot be null in well-defined C++ code`` over wording like ``this pointer
162162
cannot be null in well-defined C++ code``.
163+
* Prefer diagnostic wording without contractions whenever possible. The single
164+
quote in a contraction can be visually distracting due to its use with
165+
syntactic constructs and contractions can be harder to understand for non-
166+
native English speakers.
163167

164168
The Format String
165169
^^^^^^^^^^^^^^^^^

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ Improvements to Clang's diagnostics
559559

560560
- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
561561

562+
- Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).
563+
562564
Improvements to Clang's time-trace
563565
----------------------------------
564566

clang/lib/Analysis/CFG.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3177,11 +3177,14 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
31773177
if (!I->isConsteval())
31783178
KnownVal = tryEvaluateBool(I->getCond());
31793179

3180-
// Add the successors. If we know that specific branches are
3180+
// Add the successors. If we know that specific branches are
31813181
// unreachable, inform addSuccessor() of that knowledge.
31823182
addSuccessor(Block, ThenBlock, /* IsReachable = */ !KnownVal.isFalse());
31833183
addSuccessor(Block, ElseBlock, /* IsReachable = */ !KnownVal.isTrue());
31843184

3185+
if (I->isConsteval())
3186+
return Block;
3187+
31853188
// Add the condition as the last statement in the new block. This may
31863189
// create new blocks as the condition may contain control-flow. Any newly
31873190
// created blocks will be pointed to be "Block".

clang/test/Driver/relax.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// RUN: llvm-readobj -r %t | FileCheck --check-prefix=REL %s
99

1010
// REL: R_X86_64_REX_GOTPCRELX foo
11-
// REL: R_X86_64_REX2_GOTPCRELX foo
11+
// REL: R_X86_64_CODE_4_GOTPCRELX foo
1212

1313
movq foo@GOTPCREL(%rip), %rax
1414
movq foo@GOTPCREL(%rip), %r16
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1-
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough -verify %s
22

33
constexpr int f() { } // expected-warning {{non-void function does not return a value}}
44
static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}
55

66
consteval int g() { } // expected-warning {{non-void function does not return a value}}
77
static_assert(__is_same(decltype([] consteval -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}
8+
9+
namespace GH116485 {
10+
int h() {
11+
if consteval { }
12+
} // expected-warning {{non-void function does not return a value}}
13+
14+
void i(int x) {
15+
if consteval {
16+
}
17+
switch (x) {
18+
case 1:
19+
i(1);
20+
case 2: // expected-warning {{unannotated fall-through between switch labels}} \
21+
// expected-note {{insert 'break;' to avoid fall-through}}
22+
break;
23+
}
24+
}
25+
26+
constexpr bool j() {
27+
if !consteval { return true; }
28+
} // expected-warning {{non-void function does not return a value in all control paths}} \
29+
// expected-note {{control reached end of constexpr function}}
30+
31+
bool k = j();
32+
constinit bool l = j(); // expected-error {{variable does not have a constant initializer}} \
33+
// expected-note {{required by 'constinit' specifier here}} \
34+
// expected-note {{in call to 'j()'}}
35+
36+
}

lld/ELF/Arch/X86_64.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ RelExpr X86_64::getRelExpr(RelType type, const Symbol &s,
394394
case R_X86_64_GOTPCREL:
395395
case R_X86_64_GOTPCRELX:
396396
case R_X86_64_REX_GOTPCRELX:
397-
case R_X86_64_REX2_GOTPCRELX:
397+
case R_X86_64_CODE_4_GOTPCRELX:
398398
case R_X86_64_GOTTPOFF:
399399
return R_GOT_PC;
400400
case R_X86_64_GOTOFF64:
@@ -738,7 +738,7 @@ int64_t X86_64::getImplicitAddend(const uint8_t *buf, RelType type) const {
738738
case R_X86_64_GOTPCREL:
739739
case R_X86_64_GOTPCRELX:
740740
case R_X86_64_REX_GOTPCRELX:
741-
case R_X86_64_REX2_GOTPCRELX:
741+
case R_X86_64_CODE_4_GOTPCRELX:
742742
case R_X86_64_PC32:
743743
case R_X86_64_GOTTPOFF:
744744
case R_X86_64_PLT32:
@@ -821,7 +821,7 @@ void X86_64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
821821
break;
822822
case R_X86_64_GOTPCRELX:
823823
case R_X86_64_REX_GOTPCRELX:
824-
case R_X86_64_REX2_GOTPCRELX:
824+
case R_X86_64_CODE_4_GOTPCRELX:
825825
if (rel.expr != R_GOT_PC) {
826826
relaxGot(loc, rel, val);
827827
} else {
@@ -873,13 +873,13 @@ void X86_64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
873873

874874
RelExpr X86_64::adjustGotPcExpr(RelType type, int64_t addend,
875875
const uint8_t *loc) const {
876-
// Only R_X86_64_[REX_]|[REX2_]GOTPCRELX can be relaxed. GNU as may emit
876+
// Only R_X86_64_[REX_]|[CODE_4_]GOTPCRELX can be relaxed. GNU as may emit
877877
// GOTPCRELX with addend != -4. Such an instruction does not load the full GOT
878878
// entry, so we cannot relax the relocation. E.g. movl x@GOTPCREL+4(%rip),
879879
// %rax (addend=0) loads the high 32 bits of the GOT entry.
880880
if (!ctx.arg.relax || addend != -4 ||
881881
(type != R_X86_64_GOTPCRELX && type != R_X86_64_REX_GOTPCRELX &&
882-
type != R_X86_64_REX2_GOTPCRELX))
882+
type != R_X86_64_CODE_4_GOTPCRELX))
883883
return R_GOT_PC;
884884
const uint8_t op = loc[-2];
885885
const uint8_t modRm = loc[-1];
@@ -1002,7 +1002,8 @@ static void relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val) {
10021002
// We are relaxing a rip relative to an absolute, so compensate
10031003
// for the old -4 addend.
10041004
assert(!rel.sym->file || !rel.sym->file->ctx.arg.isPic);
1005-
relaxGotNoPic(loc, val + 4, op, modRm, rel.type == R_X86_64_REX2_GOTPCRELX);
1005+
relaxGotNoPic(loc, val + 4, op, modRm,
1006+
rel.type == R_X86_64_CODE_4_GOTPCRELX);
10061007
return;
10071008
}
10081009

lld/test/ELF/x86-64-gotpc-no-relax-err.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# CHECK-NEXT: error: {{.*}}:(.text+0x9): relocation R_X86_64_REX_GOTPCRELX out of range: 2147483659 is not in [-2147483648, 2147483647]; references '__stop_data'
1414
# CHECK-NEXT: >>> defined in <internal>
1515
# CHECK-EMPTY:
16-
# CHECK-NEXT: error: {{.*}}:(.text+0x11): relocation R_X86_64_REX2_GOTPCRELX out of range: 2147483651 is not in [-2147483648, 2147483647]; references '__stop_data'
16+
# CHECK-NEXT: error: {{.*}}:(.text+0x11): relocation R_X86_64_CODE_4_GOTPCRELX out of range: 2147483651 is not in [-2147483648, 2147483647]; references '__stop_data'
1717
# CHECK-NEXT: >>> defined in <internal>
1818

1919
#--- a.s

lld/test/ELF/x86-64-gotpc-relax-nopic.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ _start:
134134
xorq bar@GOTPCREL(%rip), %r8
135135
testq %r15, bar@GOTPCREL(%rip)
136136

137-
## R_X86_64_REX2_GOTPCRELX
137+
## R_X86_64_CODE_4_GOTPCRELX
138138
adcq bar@GOTPCREL(%rip), %r16
139139
addq bar@GOTPCREL(%rip), %r17
140140
andq bar@GOTPCREL(%rip), %r18

lld/test/ELF/x86-64-gotpc-relax.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# REQUIRES: x86
2-
## Test R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX/R_X86_64_REX2_GOTPCRELX GOT optimization.
2+
## Test R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX/R_X86_64_CODE_4_GOTPCRELX GOT optimization.
33

44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
55
# RUN: ld.lld %t.o -o %t1 --no-apply-dynamic-relocs

0 commit comments

Comments
 (0)