Skip to content

Commit 365faf3

Browse files
committed
Merge from 'main' to 'sycl-web' (38 commits)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaDeclCXX.cpp
2 parents 17fe1b5 + 6a99326 commit 365faf3

File tree

188 files changed

+17116
-1979
lines changed

Some content is hidden

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

188 files changed

+17116
-1979
lines changed

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/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/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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,12 @@ Improvements to Clang's diagnostics
678678
- Clang now accepts ``@tparam`` comments on variable template partial
679679
specializations. (#GH144775)
680680

681+
- Fixed a bug that caused diagnostic line wrapping to not function correctly on
682+
some systems. (#GH139499)
683+
684+
- Clang now tries to avoid printing file paths that contain ``..``, instead preferring
685+
the canonical file path if it ends up being shorter.
686+
681687
Improvements to Clang's time-trace
682688
----------------------------------
683689

@@ -914,6 +920,9 @@ Bug Fixes to C++ Support
914920
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
915921
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
916922
- Fix a crash when trying to instantiate an ambiguous specialization. (#GH51866)
923+
- Improved handling of variables with ``consteval`` constructors, to
924+
consistently treat the initializer as manifestly constant-evaluated.
925+
(#GH135281)
917926

918927
Bug Fixes to AST Handling
919928
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ TARGET_BUILTIN(__builtin_amdgcn_smfmac_f32_32x32x32_fp8_fp8, "V16fV2iV4iV16fiIiI
429429

430430
TARGET_BUILTIN(__builtin_amdgcn_cvt_f32_bf8, "fiIi", "nc", "fp8-conversion-insts")
431431
TARGET_BUILTIN(__builtin_amdgcn_cvt_f32_fp8, "fiIi", "nc", "fp8-conversion-insts")
432+
TARGET_BUILTIN(__builtin_amdgcn_cvt_f32_fp8_e5m3, "fiIi", "nc", "fp8e5m3-insts")
432433
TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_f32_bf8, "V2fiIb", "nc", "fp8-conversion-insts")
433434
TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_f32_fp8, "V2fiIb", "nc", "fp8-conversion-insts")
434435
TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_bf8_f32, "iffiIb", "nc", "fp8-conversion-insts")

clang/include/clang/CIR/Dialect/IR/CIRTypes.td

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,12 @@ def CIR_RecordType : CIR_Type<"Record", "record", [
509509
A few examples:
510510

511511
```mlir
512-
!complete = !cir.record<struct "complete" {!cir.int<u, 8>}>
513-
!incomplete = !cir.record<struct "incomplete" incomplete>
514-
!anonymous = !cir.record<struct {!cir.int<u, 8>}>
512+
!rec_complete = !cir.record<struct "complete" {!u8i}>
513+
!rec_incomplete = !cir.record<struct "incomplete" incomplete>
514+
!anonymous_struct = !cir.record<struct {!u8i}>
515+
!rec_p1 = !cir.record<struct "p1" packed {!u8i, !u8i}>
516+
!rec_p2 = !cir.record<struct "p2" padded {!u8i, !u8i}>
517+
!rec_p3 = !cir.record<struct "p3" packed padded {!s32i, !u8i, !u8i}>
515518
```
516519

517520
Incomplete records are mutable, meaning they can be later completed with a
@@ -552,7 +555,7 @@ def CIR_RecordType : CIR_Type<"Record", "record", [
552555
"bool":$padded,
553556
"RecordKind":$kind
554557
), [{
555-
return $_get($_ctxt, members, name, /*complete=*/true, packed, padded,
558+
return $_get($_ctxt, members, name, /*incomplete=*/false, packed, padded,
556559
kind);
557560
}]>,
558561

@@ -564,6 +567,17 @@ def CIR_RecordType : CIR_Type<"Record", "record", [
564567
return $_get($_ctxt, /*members=*/llvm::ArrayRef<Type>{}, name,
565568
/*incomplete=*/true, /*packed=*/false,
566569
/*padded=*/false, kind);
570+
}]>,
571+
572+
// Create an anonymous record type (always complete).
573+
TypeBuilder<(ins
574+
"llvm::ArrayRef<mlir::Type>":$members,
575+
"bool":$packed,
576+
"bool":$padded,
577+
"RecordKind":$kind
578+
), [{
579+
return $_get($_ctxt, members, mlir::StringAttr{}, /*incomplete=*/false,
580+
packed, padded, kind);
567581
}]>];
568582

569583
let extraClassDeclaration = [{

clang/include/clang/Lex/LexHLSLRootSignature.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ struct RootSignatureToken {
3131

3232
Kind TokKind = Kind::invalid;
3333

34-
// Retain the SouceLocation of the token for diagnostics
35-
clang::SourceLocation TokLoc;
34+
// Retain the location offset of the token in the Signature
35+
// string
36+
uint32_t LocOffset;
3637

3738
// Retain spelling of an numeric constant to be parsed later
3839
StringRef NumSpelling;
3940

4041
// Constructors
41-
RootSignatureToken(clang::SourceLocation TokLoc) : TokLoc(TokLoc) {}
42-
RootSignatureToken(Kind TokKind, clang::SourceLocation TokLoc)
43-
: TokKind(TokKind), TokLoc(TokLoc) {}
42+
RootSignatureToken(uint32_t LocOffset) : LocOffset(LocOffset) {}
43+
RootSignatureToken(Kind TokKind, uint32_t LocOffset)
44+
: TokKind(TokKind), LocOffset(LocOffset) {}
4445
};
4546

4647
inline const DiagnosticBuilder &
@@ -61,8 +62,7 @@ operator<<(const DiagnosticBuilder &DB, const RootSignatureToken::Kind Kind) {
6162

6263
class RootSignatureLexer {
6364
public:
64-
RootSignatureLexer(StringRef Signature, clang::SourceLocation SourceLoc)
65-
: Buffer(Signature), SourceLoc(SourceLoc) {}
65+
RootSignatureLexer(StringRef Signature) : Buffer(Signature) {}
6666

6767
/// Consumes and returns the next token.
6868
RootSignatureToken consumeToken();
@@ -76,23 +76,21 @@ class RootSignatureLexer {
7676
}
7777

7878
private:
79-
// Internal buffer to iterate over
79+
// Internal buffer state
8080
StringRef Buffer;
81+
uint32_t LocOffset = 0;
8182

8283
// Current peek state
8384
std::optional<RootSignatureToken> NextToken = std::nullopt;
8485

85-
// Passed down parameters from Sema
86-
clang::SourceLocation SourceLoc;
87-
8886
/// Consumes the buffer and returns the lexed token.
8987
RootSignatureToken lexToken();
9088

9189
/// Advance the buffer by the specified number of characters.
9290
/// Updates the SourceLocation appropriately.
9391
void advanceBuffer(unsigned NumCharacters = 1) {
9492
Buffer = Buffer.drop_front(NumCharacters);
95-
SourceLoc = SourceLoc.getLocWithOffset(NumCharacters);
93+
LocOffset += NumCharacters;
9694
}
9795
};
9896

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
1414
#define LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
1515

16+
#include "clang/AST/Expr.h"
1617
#include "clang/Basic/DiagnosticParse.h"
1718
#include "clang/Lex/LexHLSLRootSignature.h"
1819
#include "clang/Lex/Preprocessor.h"
@@ -29,7 +30,7 @@ class RootSignatureParser {
2930
public:
3031
RootSignatureParser(llvm::dxbc::RootSignatureVersion Version,
3132
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
32-
RootSignatureLexer &Lexer, clang::Preprocessor &PP);
33+
StringLiteral *Signature, Preprocessor &PP);
3334

3435
/// Consumes tokens from the Lexer and constructs the in-memory
3536
/// representations of the RootElements. Tokens are consumed until an
@@ -187,12 +188,23 @@ class RootSignatureParser {
187188
bool tryConsumeExpectedToken(RootSignatureToken::Kind Expected);
188189
bool tryConsumeExpectedToken(ArrayRef<RootSignatureToken::Kind> Expected);
189190

191+
/// Convert the token's offset in the signature string to its SourceLocation
192+
///
193+
/// This allows to currently retrieve the location for multi-token
194+
/// StringLiterals
195+
SourceLocation getTokenLocation(RootSignatureToken Tok);
196+
197+
/// Construct a diagnostics at the location of the current token
198+
DiagnosticBuilder reportDiag(unsigned DiagID) {
199+
return getDiags().Report(getTokenLocation(CurToken), DiagID);
200+
}
201+
190202
private:
191203
llvm::dxbc::RootSignatureVersion Version;
192204
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements;
193-
RootSignatureLexer &Lexer;
194-
195-
clang::Preprocessor &PP;
205+
StringLiteral *Signature;
206+
RootSignatureLexer Lexer;
207+
Preprocessor &PP;
196208

197209
RootSignatureToken CurToken;
198210
};

0 commit comments

Comments
 (0)