Skip to content

Commit c491482

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3008)
2 parents f221d0d + 3549d41 commit c491482

File tree

1,095 files changed

+47792
-12943
lines changed

Some content is hidden

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

1,095 files changed

+47792
-12943
lines changed

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24412441

24422442
assert(FKI.TargetOffset == 0 && "0-bit relocation offset expected");
24432443
const uint64_t RelOffset = Fixup.getOffset();
2444+
auto [RelSymbol, RelAddend] = extractFixupExpr(Fixup);
24442445

24452446
uint32_t RelType;
24462447
if (Fixup.isPCRel()) {
@@ -2452,6 +2453,9 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24522453
case 32: RelType = ELF::R_X86_64_PC32; break;
24532454
case 64: RelType = ELF::R_X86_64_PC64; break;
24542455
}
2456+
// Adjust PC-relative fixup offsets, which are calculated from the start
2457+
// of the next instruction.
2458+
RelAddend -= FKI.TargetSize / 8;
24552459
} else {
24562460
switch (FKI.TargetSize) {
24572461
default:
@@ -2463,8 +2467,6 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24632467
}
24642468
}
24652469

2466-
auto [RelSymbol, RelAddend] = extractFixupExpr(Fixup);
2467-
24682470
return Relocation({RelOffset, RelSymbol, RelType, RelAddend, 0});
24692471
}
24702472

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ namespace clang::tidy {
5555

5656
namespace {
5757
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
58-
static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
58+
static constexpr llvm::StringLiteral AnalyzerCheckNamePrefix =
59+
"clang-analyzer-";
5960

6061
class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
6162
public:
@@ -351,10 +352,9 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
351352
static void
352353
setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
353354
clang::AnalyzerOptions &AnalyzerOptions) {
354-
StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
355355
for (const auto &Opt : Opts.CheckOptions) {
356356
StringRef OptName(Opt.getKey());
357-
if (!OptName.consume_front(AnalyzerPrefix))
357+
if (!OptName.consume_front(AnalyzerCheckNamePrefix))
358358
continue;
359359
// Analyzer options are always local options so we can ignore priority.
360360
AnalyzerOptions.Config[OptName] = Opt.getValue().Value;
@@ -476,7 +476,8 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
476476
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
477477
for (const auto &AnalyzerCheck : getAnalyzerCheckersAndPackages(
478478
Context, Context.canEnableAnalyzerAlphaCheckers()))
479-
CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
479+
CheckNames.emplace_back(
480+
(AnalyzerCheckNamePrefix + AnalyzerCheck.first).str());
480481
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
481482

482483
llvm::sort(CheckNames);

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
544544
case clang::DiagnosticsEngine::ak_attr:
545545
Builder << reinterpret_cast<Attr *>(Info.getRawArg(Index));
546546
break;
547+
case clang::DiagnosticsEngine::ak_attr_info:
548+
Builder << reinterpret_cast<AttributeCommonInfo *>(Info.getRawArg(Index));
549+
break;
547550
case clang::DiagnosticsEngine::ak_addrspace:
548551
Builder << static_cast<LangAS>(Info.getRawArg(Index));
549552
break;

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ AST_POLYMORPHIC_MATCHER(
4646
if (PrefixPosition == StringRef::npos)
4747
return false;
4848
Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
49-
static const char *AbseilLibraries[] = {
49+
static constexpr llvm::StringLiteral AbseilLibraries[] = {
5050
"algorithm", "base", "container", "debugging", "flags",
5151
"hash", "iterator", "memory", "meta", "numeric",
5252
"profiling", "random", "status", "strings", "synchronization",
5353
"time", "types", "utility"};
54-
return llvm::any_of(AbseilLibraries, [&](const char *Library) {
54+
return llvm::any_of(AbseilLibraries, [&](llvm::StringLiteral Library) {
5555
return Path.starts_with(Library);
5656
});
5757
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace {
2525

2626
AST_MATCHER(CXXMethodDecl, isVirtual) { return Node.isVirtual(); }
2727

28-
static const char *const ErrorMsg =
28+
static constexpr llvm::StringLiteral ErrorMsg =
2929
"comparing a pointer to member virtual function with other pointer is "
3030
"unspecified behavior, only compare it with a null-pointer constant for "
3131
"equality.";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ TaggedUnionMemberCountCheck::getNumberOfEnumValues(const EnumDecl *ED) {
144144

145145
if (EnableCountingEnumHeuristic && LastEnumConstant &&
146146
isCountingEnumLikeName(LastEnumConstant->getName()) &&
147-
(LastEnumConstant->getInitVal() == (EnumValues.size() - 1))) {
147+
llvm::APSInt::isSameValue(LastEnumConstant->getInitVal(),
148+
llvm::APSInt::get(EnumValues.size() - 1))) {
148149
return {EnumValues.size() - 1, LastEnumConstant};
149150
}
150151

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ static bool isEmpty(ASTContext &Context, const QualType &Type) {
373373
return isIncompleteOrZeroLengthArrayType(Context, Type);
374374
}
375375

376-
static const char *getInitializer(QualType QT, bool UseAssignment) {
377-
const char *DefaultInitializer = "{}";
376+
static llvm::StringLiteral getInitializer(QualType QT, bool UseAssignment) {
377+
static constexpr llvm::StringLiteral DefaultInitializer = "{}";
378378
if (!UseAssignment)
379379
return DefaultInitializer;
380380

clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
119119
if (StartLoc.isMacroID() && IgnoreMacros)
120120
return;
121121

122-
static const char *UseUsingWarning = "use 'using' instead of 'typedef'";
122+
static constexpr llvm::StringLiteral UseUsingWarning =
123+
"use 'using' instead of 'typedef'";
123124

124125
// Warn at StartLoc but do not fix if there is macro or array.
125126
if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID()) {

clang/docs/ReleaseNotes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,12 @@ Improvements to Clang's diagnostics
694694
- Clang now accepts ``@tparam`` comments on variable template partial
695695
specializations. (#GH144775)
696696

697+
- Fixed a bug that caused diagnostic line wrapping to not function correctly on
698+
some systems. (#GH139499)
699+
700+
- Clang now tries to avoid printing file paths that contain ``..``, instead preferring
701+
the canonical file path if it ends up being shorter.
702+
697703
Improvements to Clang's time-trace
698704
----------------------------------
699705

@@ -772,6 +778,11 @@ Bug Fixes in This Version
772778
- Fixed an infinite recursion when checking constexpr destructors. (#GH141789)
773779
- Fixed a crash when a malformed using declaration appears in a ``constexpr`` function. (#GH144264)
774780
- Fixed a bug when use unicode character name in macro concatenation. (#GH145240)
781+
- Clang doesn't erroneously inject a ``static_assert`` macro in ms-compatibility and
782+
-std=c99 mode. This resulted in deletion of ``-W/Wno-microsoft-static-assert``
783+
flag and diagnostic because the macro injection was used to emit this warning.
784+
Unfortunately there is no other good way to diagnose usage of ``static_assert``
785+
macro without inclusion of ``<assert.h>``.
775786

776787
Bug Fixes to Compiler Builtins
777788
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -909,6 +920,7 @@ Bug Fixes to C++ Support
909920
- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` and ``alignas`` attributes for declarations (#GH133107)
910921
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
911922
- Fixed a function declaration mismatch that caused inconsistencies between concepts and variable template declarations. (#GH139476)
923+
- Fixed an out-of-line declaration mismatch involving nested template parameters. (#GH145521)
912924
- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616).
913925
- Fix an incorrect deduction when calling an explicit object member function template through an overload set address.
914926
- Fixed bug in constant evaluation that would allow using the value of a
@@ -923,6 +935,10 @@ Bug Fixes to C++ Support
923935
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
924936
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
925937
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
938+
- Fix a crash when trying to instantiate an ambiguous specialization. (#GH51866)
939+
- Improved handling of variables with ``consteval`` constructors, to
940+
consistently treat the initializer as manifestly constant-evaluated.
941+
(#GH135281)
926942

927943
Bug Fixes to AST Handling
928944
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Expr.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,6 +3534,10 @@ class CompoundLiteralExpr : public Expr {
35343534
/// The int part of the pair stores whether this expr is file scope.
35353535
llvm::PointerIntPair<TypeSourceInfo *, 1, bool> TInfoAndScope;
35363536
Stmt *Init;
3537+
3538+
/// Value of constant literals with static storage duration.
3539+
mutable APValue *StaticValue = nullptr;
3540+
35373541
public:
35383542
CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo,
35393543
QualType T, ExprValueKind VK, Expr *init, bool fileScope)
@@ -3563,6 +3567,10 @@ class CompoundLiteralExpr : public Expr {
35633567
TInfoAndScope.setPointer(tinfo);
35643568
}
35653569

3570+
bool hasStaticStorage() const { return isFileScope() && isGLValue(); }
3571+
APValue &getOrCreateStaticValue(ASTContext &Ctx) const;
3572+
APValue &getStaticValue() const;
3573+
35663574
SourceLocation getBeginLoc() const LLVM_READONLY {
35673575
// FIXME: Init should never be null.
35683576
if (!Init)

0 commit comments

Comments
 (0)