Skip to content

Commit 31272f8

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:ee4e8197fa67 into origin/amd-gfx:543f39bd900d
Local branch origin/amd-gfx 543f39b Merged main:f99072bd8c6b into origin/amd-gfx:76d6615e816f Remote branch main ee4e819 [LLVM][AArch64][SVE] Mark DUP immediate instructions with isAsCheapAsAMove. (llvm#133945)
2 parents 543f39b + ee4e819 commit 31272f8

File tree

496 files changed

+16080
-10084
lines changed

Some content is hidden

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

496 files changed

+16080
-10084
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
311311
: Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
312312
RemoveIncompatibleErrors(RemoveIncompatibleErrors),
313313
GetFixesFromNotes(GetFixesFromNotes),
314-
EnableNolintBlocks(EnableNolintBlocks) {
315-
316-
if (Context.getOptions().HeaderFilterRegex &&
317-
!Context.getOptions().HeaderFilterRegex->empty())
318-
HeaderFilter =
319-
std::make_unique<llvm::Regex>(*Context.getOptions().HeaderFilterRegex);
320-
321-
if (Context.getOptions().ExcludeHeaderFilterRegex &&
322-
!Context.getOptions().ExcludeHeaderFilterRegex->empty())
323-
ExcludeHeaderFilter = std::make_unique<llvm::Regex>(
324-
*Context.getOptions().ExcludeHeaderFilterRegex);
325-
}
314+
EnableNolintBlocks(EnableNolintBlocks) {}
326315

327316
void ClangTidyDiagnosticConsumer::finalizeLastError() {
328317
if (!Errors.empty()) {
@@ -571,17 +560,30 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
571560
}
572561

573562
StringRef FileName(File->getName());
574-
LastErrorRelatesToUserCode =
575-
LastErrorRelatesToUserCode || Sources.isInMainFile(Location) ||
576-
(HeaderFilter &&
577-
(HeaderFilter->match(FileName) &&
578-
!(ExcludeHeaderFilter && ExcludeHeaderFilter->match(FileName))));
563+
LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
564+
Sources.isInMainFile(Location) ||
565+
(getHeaderFilter()->match(FileName) &&
566+
!getExcludeHeaderFilter()->match(FileName));
579567

580568
unsigned LineNumber = Sources.getExpansionLineNumber(Location);
581569
LastErrorPassesLineFilter =
582570
LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);
583571
}
584572

573+
llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {
574+
if (!HeaderFilter)
575+
HeaderFilter =
576+
std::make_unique<llvm::Regex>(*Context.getOptions().HeaderFilterRegex);
577+
return HeaderFilter.get();
578+
}
579+
580+
llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {
581+
if (!ExcludeHeaderFilter)
582+
ExcludeHeaderFilter = std::make_unique<llvm::Regex>(
583+
*Context.getOptions().ExcludeHeaderFilterRegex);
584+
return ExcludeHeaderFilter.get();
585+
}
586+
585587
void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
586588
// Each error is modelled as the set of intervals in which it applies
587589
// replacements. To detect overlapping replacements, we use a sweep line

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
302302
/// context.
303303
llvm::Regex *getHeaderFilter();
304304

305+
/// Returns the \c ExcludeHeaderFilter constructed for the options set in the
306+
/// context.
307+
llvm::Regex *getExcludeHeaderFilter();
308+
305309
/// Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter
306310
/// according to the diagnostic \p Location.
307311
void checkFilters(SourceLocation Location, const SourceManager &Sources);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
194194
Options.WarningsAsErrors = "";
195195
Options.HeaderFileExtensions = {"", "h", "hh", "hpp", "hxx"};
196196
Options.ImplementationFileExtensions = {"c", "cc", "cpp", "cxx"};
197-
Options.HeaderFilterRegex = std::nullopt;
198-
Options.ExcludeHeaderFilterRegex = std::nullopt;
197+
Options.HeaderFilterRegex = "";
198+
Options.ExcludeHeaderFilterRegex = "";
199199
Options.SystemHeaders = false;
200200
Options.FormatStyle = "none";
201201
Options.User = std::nullopt;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Improvements to clang-tidy
9494
- Improved :program:`clang-tidy-diff.py` script. Add the `-warnings-as-errors`
9595
argument to treat warnings as errors.
9696

97+
- Fixed bug in :program:`clang-tidy` by which `HeaderFilterRegex` did not take
98+
effect when passed via the `.clang-tidy` file.
99+
97100
New checks
98101
^^^^^^^^^^
99102

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HeaderFilterRegex: '.*'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: clang-tidy -checks=-*,google-explicit-constructor %s 2>&1 | FileCheck %s
2+
#include "foo.h"
3+
// CHECK: foo.h:1:12: warning: single-argument constructors must be marked explicit
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct X { X(int); };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
InheritParentConfig: true
2+
HeaderFilterRegex: 'subfolder/.*'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// shell is required for the "dirname" command
2+
// REQUIRES: shell
3+
// RUN: clang-tidy -checks=-*,google-explicit-constructor %s -- -I "$(dirname %S)" 2>&1 | FileCheck %s
4+
#include "foo.h"
5+
// CHECK-NOT: foo.h:1:12: warning: single-argument constructors must be marked explicit
6+
7+
#include "bar.h"
8+
// CHECK: bar.h:1:13: warning: single-argument constructors must be marked explicit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct XX { XX(int); };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HeaderFilterRegex: '.*'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: clang-tidy -checks=-*,google-explicit-constructor %s 2>&1 | FileCheck %s
2+
#include "foo.h"
3+
// CHECK: foo.h:1:12: warning: single-argument constructors must be marked explicit
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct X { X(int); };

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Non-comprehensive list of changes in this release
167167

168168
- Support parsing the `cc` operand modifier and alias it to the `c` modifier (#GH127719).
169169
- Added `__builtin_elementwise_exp10`.
170+
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
170171

171172
New Compiler Flags
172173
------------------
@@ -189,6 +190,8 @@ Modified Compiler Flags
189190

190191
- The compiler flag `-fbracket-depth` default value is increased from 256 to 2048. (#GH94728)
191192

193+
- `-Wpadded` option implemented for the `x86_64-windows-msvc` target. Fixes #61702
194+
192195
Removed Compiler Flags
193196
-------------------------
194197

@@ -362,6 +365,7 @@ Bug Fixes to Attribute Support
362365
Bug Fixes to C++ Support
363366
^^^^^^^^^^^^^^^^^^^^^^^^
364367

368+
- Clang now supports implicitly defined comparison operators for friend declarations. (#GH132249)
365369
- Clang now diagnoses copy constructors taking the class by value in template instantiations. (#GH130866)
366370
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
367371
- Clang now prints the correct instantiation context for diagnostics suppressed

clang/include/clang/AST/ASTContext.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,10 +1795,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
17951795
QualType Wrapped, QualType Contained,
17961796
const HLSLAttributedResourceType::Attributes &Attrs);
17971797

1798-
QualType
1799-
getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
1800-
unsigned Index,
1801-
std::optional<unsigned> PackIndex) const;
1798+
QualType getSubstTemplateTypeParmType(QualType Replacement,
1799+
Decl *AssociatedDecl, unsigned Index,
1800+
std::optional<unsigned> PackIndex,
1801+
bool Final) const;
18021802
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
18031803
unsigned Index, bool Final,
18041804
const TemplateArgument &ArgPack);
@@ -2393,10 +2393,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
23932393
TemplateName
23942394
getDependentTemplateName(const DependentTemplateStorage &Name) const;
23952395

2396-
TemplateName
2397-
getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
2398-
unsigned Index,
2399-
std::optional<unsigned> PackIndex) const;
2396+
TemplateName getSubstTemplateTemplateParm(TemplateName replacement,
2397+
Decl *AssociatedDecl,
2398+
unsigned Index,
2399+
std::optional<unsigned> PackIndex,
2400+
bool Final) const;
24002401
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack,
24012402
Decl *AssociatedDecl,
24022403
unsigned Index,

clang/include/clang/AST/ExprCXX.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4514,7 +4514,9 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45144514
llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndRef;
45154515

45164516
unsigned Index : 15;
4517-
unsigned PackIndex : 16;
4517+
unsigned PackIndex : 15;
4518+
LLVM_PREFERRED_TYPE(bool)
4519+
unsigned Final : 1;
45184520

45194521
explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty)
45204522
: Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
@@ -4523,11 +4525,12 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45234525
SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind,
45244526
SourceLocation Loc, Expr *Replacement,
45254527
Decl *AssociatedDecl, unsigned Index,
4526-
std::optional<unsigned> PackIndex, bool RefParam)
4528+
std::optional<unsigned> PackIndex, bool RefParam,
4529+
bool Final)
45274530
: Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary),
45284531
Replacement(Replacement),
45294532
AssociatedDeclAndRef(AssociatedDecl, RefParam), Index(Index),
4530-
PackIndex(PackIndex ? *PackIndex + 1 : 0) {
4533+
PackIndex(PackIndex ? *PackIndex + 1 : 0), Final(Final) {
45314534
assert(AssociatedDecl != nullptr);
45324535
SubstNonTypeTemplateParmExprBits.NameLoc = Loc;
45334536
setDependence(computeDependence(this));
@@ -4555,6 +4558,10 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45554558
return PackIndex - 1;
45564559
}
45574560

4561+
// This substitution is Final, which means the substitution is fully
4562+
// sugared: it doesn't need to be resugared later.
4563+
bool getFinal() const { return Final; }
4564+
45584565
NonTypeTemplateParmDecl *getParameter() const;
45594566

45604567
bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
@@ -4598,7 +4605,10 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
45984605
const TemplateArgument *Arguments;
45994606

46004607
/// The number of template arguments in \c Arguments.
4601-
unsigned NumArguments : 16;
4608+
unsigned NumArguments : 15;
4609+
4610+
LLVM_PREFERRED_TYPE(bool)
4611+
unsigned Final : 1;
46024612

46034613
unsigned Index : 16;
46044614

@@ -4612,7 +4622,8 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
46124622
SubstNonTypeTemplateParmPackExpr(QualType T, ExprValueKind ValueKind,
46134623
SourceLocation NameLoc,
46144624
const TemplateArgument &ArgPack,
4615-
Decl *AssociatedDecl, unsigned Index);
4625+
Decl *AssociatedDecl, unsigned Index,
4626+
bool Final);
46164627

46174628
/// A template-like entity which owns the whole pattern being substituted.
46184629
/// This will own a set of template parameters.
@@ -4622,6 +4633,10 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
46224633
/// This should match the result of `getParameterPack()->getIndex()`.
46234634
unsigned getIndex() const { return Index; }
46244635

4636+
// This substitution will be Final, which means the substitution will be fully
4637+
// sugared: it doesn't need to be resugared later.
4638+
bool getFinal() const { return Final; }
4639+
46254640
/// Retrieve the non-type template parameter pack being substituted.
46264641
NonTypeTemplateParmDecl *getParameterPack() const;
46274642

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
191191

192192
virtual ExtKind hasExternalDefinitions(const Decl *D);
193193

194+
/// True if this function declaration was a definition before in its own
195+
/// module.
196+
virtual bool wasThisDeclarationADefinition(const FunctionDecl *FD);
197+
194198
/// Finds all declarations lexically contained within the given
195199
/// DeclContext, after applying an optional filter predicate.
196200
///

clang/include/clang/AST/PropertiesBase.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,9 @@ let Class = PropertyTypeCase<TemplateName, "SubstTemplateTemplateParm"> in {
730730
def : Property<"packIndex", Optional<UInt32>> {
731731
let Read = [{ parm->getPackIndex() }];
732732
}
733+
def : Property<"final", Bool> { let Read = [{ parm->getFinal() }]; }
733734
def : Creator<[{
734-
return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex);
735+
return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex, final);
735736
}]>;
736737
}
737738
let Class = PropertyTypeCase<TemplateName, "SubstTemplateTemplateParmPack"> in {

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,24 +829,42 @@ class OpenACCUpdateConstruct final
829829

830830
// This class represents the 'atomic' construct, which has an associated
831831
// statement, but no clauses.
832-
class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
832+
class OpenACCAtomicConstruct final
833+
: public OpenACCAssociatedStmtConstruct,
834+
private llvm::TrailingObjects<OpenACCAtomicConstruct,
835+
const OpenACCClause *> {
833836

834837
friend class ASTStmtReader;
838+
friend TrailingObjects;
835839
OpenACCAtomicKind AtomicKind = OpenACCAtomicKind::None;
836840

837-
OpenACCAtomicConstruct(EmptyShell)
841+
OpenACCAtomicConstruct(unsigned NumClauses)
838842
: OpenACCAssociatedStmtConstruct(
839843
OpenACCAtomicConstructClass, OpenACCDirectiveKind::Atomic,
840844
SourceLocation{}, SourceLocation{}, SourceLocation{},
841-
/*AssociatedStmt=*/nullptr) {}
845+
/*AssociatedStmt=*/nullptr) {
846+
std::uninitialized_value_construct(
847+
getTrailingObjects<const OpenACCClause *>(),
848+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
849+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
850+
NumClauses));
851+
}
842852

843853
OpenACCAtomicConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
844854
OpenACCAtomicKind AtKind, SourceLocation End,
855+
ArrayRef<const OpenACCClause *> Clauses,
845856
Stmt *AssociatedStmt)
846857
: OpenACCAssociatedStmtConstruct(OpenACCAtomicConstructClass,
847858
OpenACCDirectiveKind::Atomic, Start,
848859
DirectiveLoc, End, AssociatedStmt),
849-
AtomicKind(AtKind) {}
860+
AtomicKind(AtKind) {
861+
// Initialize the trailing storage.
862+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
863+
getTrailingObjects<const OpenACCClause *>());
864+
865+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
866+
Clauses.size()));
867+
}
850868

851869
void setAssociatedStmt(Stmt *S) {
852870
OpenACCAssociatedStmtConstruct::setAssociatedStmt(S);
@@ -857,10 +875,12 @@ class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
857875
return T->getStmtClass() == OpenACCAtomicConstructClass;
858876
}
859877

860-
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C);
878+
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C,
879+
unsigned NumClauses);
861880
static OpenACCAtomicConstruct *
862881
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
863-
OpenACCAtomicKind AtKind, SourceLocation End, Stmt *AssociatedStmt);
882+
OpenACCAtomicKind AtKind, SourceLocation End,
883+
ArrayRef<const OpenACCClause *> Clauses, Stmt *AssociatedStmt);
864884

865885
OpenACCAtomicKind getAtomicKind() const { return AtomicKind; }
866886
const Stmt *getAssociatedStmt() const {

clang/include/clang/AST/TemplateName.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,11 @@ class SubstTemplateTemplateParmStorage
414414

415415
SubstTemplateTemplateParmStorage(TemplateName Replacement,
416416
Decl *AssociatedDecl, unsigned Index,
417-
std::optional<unsigned> PackIndex)
417+
std::optional<unsigned> PackIndex,
418+
bool Final)
418419
: UncommonTemplateNameStorage(SubstTemplateTemplateParm, Index,
419-
PackIndex ? *PackIndex + 1 : 0),
420+
((PackIndex ? *PackIndex + 1 : 0) << 1) |
421+
Final),
420422
Replacement(Replacement), AssociatedDecl(AssociatedDecl) {
421423
assert(AssociatedDecl != nullptr);
422424
}
@@ -430,10 +432,15 @@ class SubstTemplateTemplateParmStorage
430432
/// This should match the result of `getParameter()->getIndex()`.
431433
unsigned getIndex() const { return Bits.Index; }
432434

435+
// This substitution is Final, which means the substitution is fully
436+
// sugared: it doesn't need to be resugared later.
437+
bool getFinal() const { return Bits.Data & 1; }
438+
433439
std::optional<unsigned> getPackIndex() const {
434-
if (Bits.Data == 0)
440+
auto Data = Bits.Data >> 1;
441+
if (Data == 0)
435442
return std::nullopt;
436-
return Bits.Data - 1;
443+
return Data - 1;
437444
}
438445

439446
TemplateTemplateParmDecl *getParameter() const;
@@ -443,7 +450,7 @@ class SubstTemplateTemplateParmStorage
443450

444451
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Replacement,
445452
Decl *AssociatedDecl, unsigned Index,
446-
std::optional<unsigned> PackIndex);
453+
std::optional<unsigned> PackIndex, bool Final);
447454
};
448455

449456
class DeducedTemplateStorage : public UncommonTemplateNameStorage,

0 commit comments

Comments
 (0)