Skip to content

Commit cd484f0

Browse files
authored
Merge branch 'main' into CppDeviceCode
2 parents fef9db1 + d204fdc commit cd484f0

File tree

35 files changed

+339
-286
lines changed

35 files changed

+339
-286
lines changed

clang-tools-extra/clang-tidy/.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Checks: >
2222
-performance-unnecessary-value-param,
2323
readability-*,
2424
-readability-avoid-nested-conditional-operator,
25-
-readability-avoid-return-with-void-value,
2625
-readability-braces-around-statements,
2726
-readability-container-contains,
2827
-readability-convert-member-functions-to-static,

clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,11 @@ void NarrowingConversionsCheck::diagNarrowTypeOrConstant(
381381
const Expr &Rhs) {
382382
APValue Constant = getConstantExprValue(Context, Rhs);
383383
if (Constant.isInt())
384-
return diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, Constant.getInt());
385-
if (Constant.isFloat())
386-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
387-
return diagNarrowType(SourceLoc, Lhs, Rhs);
384+
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, Constant.getInt());
385+
else if (Constant.isFloat())
386+
diagNarrowConstant(SourceLoc, Lhs, Rhs);
387+
else
388+
diagNarrowType(SourceLoc, Lhs, Rhs);
388389
}
389390

390391
void NarrowingConversionsCheck::handleIntegralCast(const ASTContext &Context,
@@ -460,10 +461,10 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
460461
llvm::APFloat FloatConstant(0.0);
461462
if (getFloatingConstantExprValue(Context, Rhs, FloatConstant)) {
462463
if (!isFloatExactlyRepresentable(Context, FloatConstant, Lhs.getType()))
463-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
464+
diagNarrowConstant(SourceLoc, Lhs, Rhs);
464465

465-
if (PedanticMode)
466-
return diagConstantCast(SourceLoc, Lhs, Rhs);
466+
else if (PedanticMode)
467+
diagConstantCast(SourceLoc, Lhs, Rhs);
467468

468469
return;
469470
}
@@ -478,7 +479,7 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
478479
void NarrowingConversionsCheck::handleFloatingToBoolean(
479480
const ASTContext &Context, SourceLocation SourceLoc, const Expr &Lhs,
480481
const Expr &Rhs) {
481-
return diagNarrowTypeOrConstant(Context, SourceLoc, Lhs, Rhs);
482+
diagNarrowTypeOrConstant(Context, SourceLoc, Lhs, Rhs);
482483
}
483484

484485
void NarrowingConversionsCheck::handleBooleanToSignedIntegral(
@@ -532,19 +533,20 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
532533
if (LhsType == RhsType)
533534
return;
534535
if (RhsType->getKind() == BuiltinType::Bool && LhsType->isSignedInteger())
535-
return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
536-
if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
537-
return handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
538-
if (RhsType->isInteger() && LhsType->isFloatingPoint())
539-
return handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
540-
if (RhsType->isInteger() && LhsType->isInteger())
541-
return handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
542-
if (RhsType->isFloatingPoint() && LhsType->getKind() == BuiltinType::Bool)
543-
return handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
544-
if (RhsType->isFloatingPoint() && LhsType->isInteger())
545-
return handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
546-
if (RhsType->isFloatingPoint() && LhsType->isFloatingPoint())
547-
return handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
536+
handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
537+
else if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
538+
handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
539+
else if (RhsType->isInteger() && LhsType->isFloatingPoint())
540+
handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
541+
else if (RhsType->isInteger() && LhsType->isInteger())
542+
handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
543+
else if (RhsType->isFloatingPoint() &&
544+
LhsType->getKind() == BuiltinType::Bool)
545+
handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
546+
else if (RhsType->isFloatingPoint() && LhsType->isInteger())
547+
handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
548+
else if (RhsType->isFloatingPoint() && LhsType->isFloatingPoint())
549+
handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
548550
}
549551

550552
bool NarrowingConversionsCheck::handleConditionalOperator(
@@ -577,21 +579,28 @@ void NarrowingConversionsCheck::handleImplicitCast(
577579
SourceLocation SourceLoc = Lhs.getExprLoc();
578580
switch (Cast.getCastKind()) {
579581
case CK_BooleanToSignedIntegral:
580-
return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
582+
handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
583+
return;
581584
case CK_IntegralToBoolean:
582-
return handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
585+
handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
586+
return;
583587
case CK_IntegralToFloating:
584-
return handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
588+
handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
589+
return;
585590
case CK_IntegralCast:
586-
return handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
591+
handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
592+
return;
587593
case CK_FloatingToBoolean:
588-
return handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
594+
handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
595+
return;
589596
case CK_FloatingToIntegral:
590-
return handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
597+
handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
598+
return;
591599
case CK_FloatingCast:
592-
return handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
600+
handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
601+
return;
593602
default:
594-
break;
603+
return;
595604
}
596605
}
597606

@@ -610,9 +619,10 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
610619

611620
void NarrowingConversionsCheck::check(const MatchFinder::MatchResult &Result) {
612621
if (const auto *Op = Result.Nodes.getNodeAs<BinaryOperator>("binary_op"))
613-
return handleBinaryOperator(*Result.Context, *Op);
614-
if (const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"))
615-
return handleImplicitCast(*Result.Context, *Cast);
616-
llvm_unreachable("must be binary operator or cast expression");
622+
handleBinaryOperator(*Result.Context, *Op);
623+
else if (const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"))
624+
handleImplicitCast(*Result.Context, *Cast);
625+
else
626+
llvm_unreachable("must be binary operator or cast expression");
617627
}
618628
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,15 @@ void ImplicitBoolConversionCheck::check(
361361
if (const auto *CastToBool =
362362
Result.Nodes.getNodeAs<ImplicitCastExpr>("implicitCastToBool")) {
363363
const auto *Parent = Result.Nodes.getNodeAs<Stmt>("parentStmt");
364-
return handleCastToBool(CastToBool, Parent, *Result.Context);
364+
handleCastToBool(CastToBool, Parent, *Result.Context);
365+
return;
365366
}
366367

367368
if (const auto *CastFromBool =
368369
Result.Nodes.getNodeAs<ImplicitCastExpr>("implicitCastFromBool")) {
369370
const auto *NextImplicitCast =
370371
Result.Nodes.getNodeAs<ImplicitCastExpr>("furtherImplicitCast");
371-
return handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);
372+
handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);
372373
}
373374
}
374375

clang/test/Analysis/undef-call.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: rm -rf %T/ctudir
2-
// RUN: mkdir %T/ctudir
3-
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
1+
// RUN: rm -rf %t.dir/ctudir
2+
// RUN: mkdir -p %t.dir/ctudir
3+
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%t.dir/ctudir -verify %s
44
// expected-no-diagnostics
55

66
struct S {

clang/test/CodeGen/thinlto_backend.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929
; Ensure f2 was imported. Check for all 3 flavors of -save-temps[=cwd|obj].
3030
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc -save-temps=obj
3131
; RUN: llvm-dis %t1.s.3.import.bc -o - | FileCheck --check-prefix=CHECK-IMPORT %s
32-
; RUN: mkdir -p %T/dir1
33-
; RUN: cd %T/dir1
32+
; RUN: mkdir -p %t.dir/dir1
33+
; RUN: cd %t.dir/dir1
3434
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc -save-temps=cwd
3535
; RUN: cd ../..
36-
; RUN: llvm-dis %T/dir1/*1.s.3.import.bc -o - | FileCheck --check-prefix=CHECK-IMPORT %s
37-
; RUN: mkdir -p %T/dir2
38-
; RUN: cd %T/dir2
36+
; RUN: llvm-dis %t.dir/dir1/*1.s.3.import.bc -o - | FileCheck --check-prefix=CHECK-IMPORT %s
37+
; RUN: mkdir -p %t.dir/dir2
38+
; RUN: cd %t.dir/dir2
3939
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc -save-temps
4040
; RUN: cd ../..
41-
; RUN: llvm-dis %T/dir2/*1.s.3.import.bc -o - | FileCheck --check-prefix=CHECK-IMPORT %s
41+
; RUN: llvm-dis %t.dir/dir2/*1.s.3.import.bc -o - | FileCheck --check-prefix=CHECK-IMPORT %s
4242
; CHECK-IMPORT: define available_externally void @f2()
4343
; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
4444
; CHECK-OBJ: T f1

clang/test/CodeGenCXX/module-intializer-pmf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %s \
3-
// RUN: -emit-module-interface -o %T/HasPMF.pcm
4-
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %T/HasPMF.pcm \
3+
// RUN: -emit-module-interface -o %t.HasPMF.pcm
4+
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t.HasPMF.pcm \
55
// RUN: -emit-llvm -o - | FileCheck %s
66

77
module;

clang/test/CodeGenCXX/profile-remap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// REQUIRES: x86-registered-target
22
//
33
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-sample-use=%S/Inputs/profile-remap.samples -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SAMPLES
4-
// RUN: llvm-profdata merge -output %T.profdata %S/Inputs/profile-remap.proftext
5-
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%T.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
6-
// RUN: llvm-profdata merge -output %T.profdata %S/Inputs/profile-remap_entry.proftext
7-
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%T.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
4+
// RUN: llvm-profdata merge -output %t.profdata %S/Inputs/profile-remap.proftext
5+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%t.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
6+
// RUN: llvm-profdata merge -output %t.profdata %S/Inputs/profile-remap_entry.proftext
7+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%t.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
88

99
namespace Foo {
1010
struct X {};

clang/test/Driver/HLSL/metal-converter.hlsl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
1+
// RUN: mkdir -p %t.dir
2+
// RUN: echo "dxv" > %t.dir/dxv && chmod 754 %t.dir/dxv
23

34
// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
45
// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
5-
// RUN: env PATH="" %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
6+
// RUN: env PATH="" %clang_dxc -T cs_6_0 %s --dxv-path=%t.dir -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
67
// NO_DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}.mtl"
78

89
// RUN: %clang_dxc -T cs_6_0 %s -metal -### 2>&1 | FileCheck --check-prefix=NO_MTL %s
910
// NO_MTL-NOT: metal-shaderconverter
1011

11-
// RUN: %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Fo %t.mtl -### 2>&1 | FileCheck --check-prefix=DXV %s
12+
// RUN: %clang_dxc -T cs_6_0 %s --dxv-path=%t.dir -metal -Fo %t.mtl -### 2>&1 | FileCheck --check-prefix=DXV %s
1213
// DXV: "{{.*}}dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}.dxo"
1314
// DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.dxo" "-o" "{{.*}}.mtl"
1415

clang/test/Driver/baremetal-sysroot.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
// Test that when a --sysroot is not provided, driver picks the default
55
// ___location correctly if available.
66

7-
// RUN: rm -rf %T/baremetal_default_sysroot
8-
// RUN: mkdir -p %T/baremetal_default_sysroot/bin
9-
// RUN: mkdir -p %T/baremetal_default_sysroot/lib/clang-runtimes/armv6m-none-eabi
10-
// RUN: ln -s %clang %T/baremetal_default_sysroot/bin/clang
7+
// RUN: rm -rf %t.dir/baremetal_default_sysroot
8+
// RUN: mkdir -p %t.dir/baremetal_default_sysroot/bin
9+
// RUN: mkdir -p %t.dir/baremetal_default_sysroot/lib/clang-runtimes/armv6m-none-eabi
10+
// RUN: ln -s %clang %t.dir/baremetal_default_sysroot/bin/clang
1111

12-
// RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### -o %t.out 2>&1 \
12+
// RUN: %t.dir/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### -o %t.out 2>&1 \
1313
// RUN: -target armv6m-none-eabi --sysroot= \
1414
// RUN: | FileCheck --check-prefix=CHECK-V6M-C %s
1515
// CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-unknown-none-eabi"

clang/test/Driver/baremetal.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@
126126
// CHECK-V6M-NDL: "-Bstatic" "-m" "armelf" "-EL"
127127
// CHECK-V6M-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
128128

129-
// RUN: rm -rf %T/baremetal_cxx_sysroot
130-
// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
129+
// RUN: rm -rf %t.dir/baremetal_cxx_sysroot
130+
// RUN: mkdir -p %t.dir/baremetal_cxx_sysroot/usr/include/c++/v1
131131
// RUN: %clangxx %s -### 2>&1 \
132132
// RUN: --target=armv6m-none-eabi \
133-
// RUN: --sysroot=%T/baremetal_cxx_sysroot \
133+
// RUN: --sysroot=%t.dir/baremetal_cxx_sysroot \
134134
// RUN: -stdlib=libc++ \
135135
// RUN: | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
136136
// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
@@ -568,24 +568,24 @@
568568

569569
// Check that compiler-rt library without the arch filename suffix will
570570
// be used if present.
571-
// RUN: rm -rf %T/baremetal_clang_rt_noarch
572-
// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
573-
// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
571+
// RUN: rm -rf %t.dir/baremetal_clang_rt_noarch
572+
// RUN: mkdir -p %t.dir/baremetal_clang_rt_noarch/lib
573+
// RUN: touch %t.dir/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
574574
// RUN: %clang %s -### 2>&1 \
575575
// RUN: --target=armv6m-none-eabi \
576-
// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
576+
// RUN: --sysroot=%t.dir/baremetal_clang_rt_noarch \
577577
// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
578578
// CHECK-CLANGRT-NOARCH: "{{[^"]*}}libclang_rt.builtins.a"
579579
// CHECK-CLANGRT-NOARCH-NOT: "{{[^"]*}}libclang_rt.builtins.a"
580580

581581
// Check that compiler-rt library with the arch filename suffix will be
582582
// used if present.
583-
// RUN: rm -rf %T/baremetal_clang_rt_arch
584-
// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
585-
// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
583+
// RUN: rm -rf %t.dir/baremetal_clang_rt_arch
584+
// RUN: mkdir -p %t.dir/baremetal_clang_rt_arch/lib
585+
// RUN: touch %t.dir/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
586586
// RUN: %clang %s -### 2>&1 \
587587
// RUN: --target=armv6m-none-eabi \
588-
// RUN: --sysroot=%T/baremetal_clang_rt_arch \
588+
// RUN: --sysroot=%t.dir/baremetal_clang_rt_arch \
589589
// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
590590
// CHECK-CLANGRT-ARCH: "{{[^"]*}}libclang_rt.builtins.a"
591591
// CHECK-CLANGRT-ARCH-NOT: "{{[^"]*}}libclang_rt.builtins.a"

0 commit comments

Comments
 (0)