Skip to content

Commit f392ebc

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3360)
2 parents 9ff0371 + 80934a4 commit f392ebc

File tree

274 files changed

+15818
-12960
lines changed

Some content is hidden

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

274 files changed

+15818
-12960
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
18181818
NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
18191819
} else {
18201820
NumNegativeBits =
1821-
std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits());
1821+
std::max(NumNegativeBits, InitVal.getSignificantBits());
18221822
}
18231823

18241824
MembersRepresentableByInt &= isRepresentableIntegerValue(InitVal, IntTy);

clang/include/clang/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "clang/AST/APNumericStorage.h"
1717
#include "clang/AST/APValue.h"
1818
#include "clang/AST/ASTVector.h"
19-
#include "clang/AST/Attr.h"
2019
#include "clang/AST/ComputeDependence.h"
2120
#include "clang/AST/Decl.h"
2221
#include "clang/AST/DeclAccessPair.h"
@@ -58,6 +57,7 @@ namespace clang {
5857
class StringLiteral;
5958
class TargetInfo;
6059
class ValueDecl;
60+
class WarnUnusedResultAttr;
6161

6262
/// A simple array of base specifiers.
6363
typedef SmallVector<CXXBaseSpecifier*, 4> CXXCastPath;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,10 +1812,7 @@ def note_unsatisfied_trait_reason
18121812
"%DeletedAssign{has a deleted %select{copy|move}1 "
18131813
"assignment operator}|"
18141814
"%UnionWithUserDeclaredSMF{is a union with a user-declared "
1815-
"%sub{select_special_member_kind}1}|"
1816-
"%FunctionType{is a function type}|"
1817-
"%CVVoidType{is a cv void type}|"
1818-
"%IncompleteArrayType{is an incomplete array type}"
1815+
"%sub{select_special_member_kind}1}"
18191816
"}0">;
18201817

18211818
def warn_consteval_if_always_true : Warning<
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//===-- CudaInstallationDetector.h - Cuda Instalation Detector --*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_DRIVER_CUDAINSTALLATIONDETECTOR_H
10+
#define LLVM_CLANG_DRIVER_CUDAINSTALLATIONDETECTOR_H
11+
12+
#include "clang/Basic/Cuda.h"
13+
#include "clang/Driver/Driver.h"
14+
#include <bitset>
15+
16+
namespace clang {
17+
namespace driver {
18+
19+
/// A class to find a viable CUDA installation
20+
class CudaInstallationDetector {
21+
private:
22+
const Driver &D;
23+
bool IsValid = false;
24+
CudaVersion Version = CudaVersion::UNKNOWN;
25+
std::string InstallPath;
26+
std::string BinPath;
27+
std::string LibDevicePath;
28+
std::string IncludePath;
29+
llvm::StringMap<std::string> LibDeviceMap;
30+
31+
// CUDA architectures for which we have raised an error in
32+
// CheckCudaVersionSupportsArch.
33+
mutable std::bitset<(int)OffloadArch::LAST> ArchsWithBadVersion;
34+
35+
public:
36+
CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
37+
const llvm::opt::ArgList &Args);
38+
39+
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
40+
llvm::opt::ArgStringList &CC1Args) const;
41+
42+
/// Emit an error if Version does not support the given Arch.
43+
///
44+
/// If either Version or Arch is unknown, does not emit an error. Emits at
45+
/// most one error per Arch.
46+
void CheckCudaVersionSupportsArch(OffloadArch Arch) const;
47+
48+
/// Check whether we detected a valid Cuda install.
49+
bool isValid() const { return IsValid; }
50+
/// Print information about the detected CUDA installation.
51+
void print(raw_ostream &OS) const;
52+
53+
/// Get the detected Cuda install's version.
54+
CudaVersion version() const {
55+
return Version == CudaVersion::NEW ? CudaVersion::PARTIALLY_SUPPORTED
56+
: Version;
57+
}
58+
/// Get the detected Cuda installation path.
59+
StringRef getInstallPath() const { return InstallPath; }
60+
/// Get the detected path to Cuda's bin directory.
61+
StringRef getBinPath() const { return BinPath; }
62+
/// Get the detected Cuda Include path.
63+
StringRef getIncludePath() const { return IncludePath; }
64+
/// Get the detected Cuda device library path.
65+
StringRef getLibDevicePath() const { return LibDevicePath; }
66+
/// Get libdevice file for given architecture
67+
std::string getLibDeviceFile(StringRef Gpu) const {
68+
return LibDeviceMap.lookup(Gpu);
69+
}
70+
void WarnIfUnsupportedVersion() const;
71+
};
72+
73+
} // namespace driver
74+
} // namespace clang
75+
76+
#endif // LLVM_CLANG_DRIVER_CUDAINSTALLATIONDETECTOR_H

clang/lib/Driver/ToolChains/LazyDetector.h renamed to clang/include/clang/Driver/LazyDetector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LAZYDETECTOR_H
10-
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LAZYDETECTOR_H
9+
#ifndef LLVM_CLANG_DRIVER_LAZYDETECTOR_H
10+
#define LLVM_CLANG_DRIVER_LAZYDETECTOR_H
1111

1212
#include "clang/Driver/Tool.h"
1313
#include "clang/Driver/ToolChain.h"
@@ -42,4 +42,4 @@ template <class T> class LazyDetector {
4242

4343
} // end namespace clang
4444

45-
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LAZYDETECTOR_H
45+
#endif // LLVM_CLANG_DRIVER_LAZYDETECTOR_H

clang/lib/Driver/ToolChains/ROCm.h renamed to clang/include/clang/Driver/RocmInstallationDetector.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
//===--- ROCm.h - ROCm installation detector --------------------*- C++ -*-===//
1+
//===-- RocmInstallationDetector.h - ROCm Instalation Detector --*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
10-
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
9+
#ifndef LLVM_CLANG_DRIVER_ROCMINSTALLATIONDETECTOR_H
10+
#define LLVM_CLANG_DRIVER_ROCMINSTALLATIONDETECTOR_H
1111

12-
#include "clang/Basic/Cuda.h"
13-
#include "clang/Basic/LLVM.h"
14-
#include "clang/Driver/CommonArgs.h"
1512
#include "clang/Driver/Driver.h"
16-
#include "clang/Driver/Options.h"
17-
#include "clang/Driver/SanitizerArgs.h"
18-
#include "llvm/ADT/SmallString.h"
19-
#include "llvm/ADT/StringMap.h"
20-
#include "llvm/Option/ArgList.h"
21-
#include "llvm/Support/VersionTuple.h"
22-
#include "llvm/TargetParser/TargetParser.h"
23-
#include "llvm/TargetParser/Triple.h"
2413

2514
namespace clang {
2615
namespace driver {
@@ -308,7 +297,7 @@ class RocmInstallationDetector {
308297
StringRef getHIPVersion() const { return DetectedVersion; }
309298
};
310299

311-
} // end namespace driver
312-
} // end namespace clang
300+
} // namespace driver
301+
} // namespace clang
313302

314-
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
303+
#endif // LLVM_CLANG_DRIVER_ROCMINSTALLATIONDETECTOR_H
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===-- SyclInstallationDetector.h - SYCL Instalation Detector --*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_DRIVER_SYCLINSTALLATIONDETECTOR_H
10+
#define LLVM_CLANG_DRIVER_SYCLINSTALLATIONDETECTOR_H
11+
12+
#include "clang/Driver/Driver.h"
13+
14+
namespace clang {
15+
namespace driver {
16+
17+
class SYCLInstallationDetector {
18+
public:
19+
SYCLInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
20+
const llvm::opt::ArgList &Args);
21+
22+
void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
23+
llvm::opt::ArgStringList &CC1Args) const;
24+
};
25+
26+
} // namespace driver
27+
} // namespace clang
28+
29+
#endif // LLVM_CLANG_DRIVER_SYCLINSTALLATIONDETECTOR_H

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,11 @@ def UndefResultChecker : Checker<"UndefinedBinaryOperatorResult">,
233233
HelpText<"Check for undefined results of binary operators">,
234234
Documentation<HasDocumentation>;
235235

236-
def StackAddrEscapeBase : Checker<"StackAddrEscapeBase">,
237-
HelpText<"Generate information about stack address escapes.">,
238-
Documentation<NotDocumented>,
239-
Hidden;
240-
241-
def StackAddrEscapeChecker : Checker<"StackAddressEscape">,
242-
HelpText<"Check that addresses to stack memory do not escape the function">,
243-
Dependencies<[StackAddrEscapeBase]>,
244-
Documentation<HasDocumentation>;
236+
def StackAddrEscapeChecker
237+
: Checker<"StackAddressEscape">,
238+
HelpText<
239+
"Check that addresses to stack memory do not escape the function">,
240+
Documentation<HasDocumentation>;
245241

246242
def DynamicTypePropagation : Checker<"DynamicTypePropagation">,
247243
HelpText<"Generate dynamic type information">,
@@ -295,10 +291,11 @@ def DynamicTypeChecker
295291
Dependencies<[DynamicTypePropagation]>,
296292
Documentation<HasDocumentation>;
297293

298-
def StackAddrAsyncEscapeChecker : Checker<"StackAddressAsyncEscape">,
299-
HelpText<"Check that addresses to stack memory do not escape the function">,
300-
Dependencies<[StackAddrEscapeBase]>,
301-
Documentation<HasDocumentation>;
294+
def StackAddrAsyncEscapeChecker
295+
: Checker<"StackAddressAsyncEscape">,
296+
HelpText<
297+
"Check that addresses to stack memory do not escape the function">,
298+
Documentation<HasDocumentation>;
302299

303300
def PthreadLockBase : Checker<"PthreadLockBase">,
304301
HelpText<"Helper registering multiple checks.">,
@@ -1047,11 +1044,6 @@ def RetainCountBase : Checker<"RetainCountBase">,
10471044

10481045
let ParentPackage = OSX in {
10491046

1050-
def NSOrCFErrorDerefChecker : Checker<"NSOrCFErrorDerefChecker">,
1051-
HelpText<"Implementation checker for NSErrorChecker and CFErrorChecker">,
1052-
Documentation<NotDocumented>,
1053-
Hidden;
1054-
10551047
def NumberObjectConversionChecker : Checker<"NumberObjectConversion">,
10561048
HelpText<"Check for erroneous conversions of objects representing numbers "
10571049
"into numbers">,
@@ -1149,9 +1141,8 @@ def ObjCSuperCallChecker : Checker<"MissingSuperCall">,
11491141
Documentation<NotDocumented>;
11501142

11511143
def NSErrorChecker : Checker<"NSError">,
1152-
HelpText<"Check usage of NSError** parameters">,
1153-
Dependencies<[NSOrCFErrorDerefChecker]>,
1154-
Documentation<HasDocumentation>;
1144+
HelpText<"Check usage of NSError** parameters">,
1145+
Documentation<HasDocumentation>;
11551146

11561147
def RetainCountChecker : Checker<"RetainCount">,
11571148
HelpText<"Check for leaks and improper reference count management">,
@@ -1253,9 +1244,8 @@ def CFRetainReleaseChecker : Checker<"CFRetainRelease">,
12531244
Documentation<HasDocumentation>;
12541245

12551246
def CFErrorChecker : Checker<"CFError">,
1256-
HelpText<"Check usage of CFErrorRef* parameters">,
1257-
Dependencies<[NSOrCFErrorDerefChecker]>,
1258-
Documentation<HasDocumentation>;
1247+
HelpText<"Check usage of CFErrorRef* parameters">,
1248+
Documentation<HasDocumentation>;
12591249

12601250
} // end "osx.coreFoundation"
12611251

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "clang/AST/Decl.h"
2222
#include "clang/AST/Expr.h"
2323
#include "clang/AST/StmtVisitor.h"
24-
#include "clang/Basic/TargetInfo.h"
2524

2625
namespace clang {
2726
class QualType;

clang/lib/AST/ByteCode/Interp.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "InterpStack.h"
2626
#include "InterpState.h"
2727
#include "MemberPointer.h"
28-
#include "Opcode.h"
2928
#include "PrimType.h"
3029
#include "Program.h"
3130
#include "State.h"
@@ -1131,8 +1130,9 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
11311130
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_past_end)
11321131
<< LHS.toDiagnosticString(S.getASTContext());
11331132
return false;
1134-
} else if (RHS.isOnePastEnd() && !LHS.isOnePastEnd() && !LHS.isZero() &&
1135-
LHS.getOffset() == 0) {
1133+
}
1134+
if (RHS.isOnePastEnd() && !LHS.isOnePastEnd() && !LHS.isZero() &&
1135+
LHS.getOffset() == 0) {
11361136
const SourceInfo &Loc = S.Current->getSource(OpPC);
11371137
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_past_end)
11381138
<< RHS.toDiagnosticString(S.getASTContext());
@@ -1150,8 +1150,9 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
11501150
const SourceInfo &Loc = S.Current->getSource(OpPC);
11511151
S.FFDiag(Loc, diag::note_constexpr_literal_comparison);
11521152
return false;
1153-
} else if (const auto *CE = dyn_cast<CallExpr>(E);
1154-
CE && IsOpaqueConstantCall(CE)) {
1153+
}
1154+
if (const auto *CE = dyn_cast<CallExpr>(E);
1155+
CE && IsOpaqueConstantCall(CE)) {
11551156
const SourceInfo &Loc = S.Current->getSource(OpPC);
11561157
S.FFDiag(Loc, diag::note_constexpr_opaque_call_comparison)
11571158
<< P.toDiagnosticString(S.getASTContext());
@@ -3266,7 +3267,8 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32663267
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
32673268
<< static_cast<unsigned>(Kind) << S.Current->getRange(OpPC);
32683269
return !Fatal;
3269-
} else if (Kind == CastKind::Volatile) {
3270+
}
3271+
if (Kind == CastKind::Volatile) {
32703272
if (!S.checkingPotentialConstantExpression()) {
32713273
const auto *E = cast<CastExpr>(S.Current->getExpr(OpPC));
32723274
if (S.getLangOpts().CPlusPlus)
@@ -3277,7 +3279,8 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
32773279
}
32783280

32793281
return false;
3280-
} else if (Kind == CastKind::Dynamic) {
3282+
}
3283+
if (Kind == CastKind::Dynamic) {
32813284
assert(!S.getLangOpts().CPlusPlus20);
32823285
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_cast)
32833286
<< diag::ConstexprInvalidCastKind::Dynamic;

0 commit comments

Comments
 (0)