Skip to content

Commit c243099

Browse files
committed
merge main into amd-staging
Change-Id: I6d642cbd4347b2d1aa5e6fd138e11b590ec5001c
2 parents b748656 + 99dc396 commit c243099

File tree

241 files changed

+36817
-4129
lines changed

Some content is hidden

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

241 files changed

+36817
-4129
lines changed

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,15 @@ TEST(LocateSymbol, All) {
10191019
void *Value;
10201020
void *getPointer() const { return Info::get^Pointer(Value); }
10211021
};
1022+
)cpp",
1023+
R"cpp(// Deducing this
1024+
struct S {
1025+
int bar(this S&);
1026+
};
1027+
void foo() {
1028+
S [[waldo]];
1029+
int x = wa^ldo.bar();
1030+
}
10221031
)cpp"};
10231032
for (const char *Test : Tests) {
10241033
Annotations T(Test);
@@ -1035,6 +1044,7 @@ TEST(LocateSymbol, All) {
10351044
TU.Code = std::string(T.code());
10361045

10371046
TU.ExtraArgs.push_back("-xobjective-c++");
1047+
TU.ExtraArgs.push_back("-std=c++23");
10381048

10391049
auto AST = TU.build();
10401050
auto Results = locateSymbolAt(AST, T.point());

clang/docs/tools/dump_format_help.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# A tool to parse the output of `clang-format --help` and update the
33
# documentation in ../ClangFormat.rst automatically.
44

5+
import argparse
56
import os
67
import re
78
import subprocess
@@ -26,7 +27,7 @@ def indent(text, columns, indent_first_line=True):
2627

2728

2829
def get_help_output():
29-
args = ["clang-format", "--help"]
30+
args = [binary, "--help"]
3031
cmd = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
3132
out, _ = cmd.communicate()
3233
out = out.decode(sys.stdout.encoding)
@@ -54,6 +55,14 @@ def validate(text, columns):
5455
print("warning: line too long:\n", line, file=sys.stderr)
5556

5657

58+
p = argparse.ArgumentParser()
59+
p.add_argument("-d", "--directory", help="directory of clang-format")
60+
opts = p.parse_args()
61+
62+
binary = "clang-format"
63+
if opts.directory:
64+
binary = opts.directory + "/" + binary
65+
5766
help_text = get_help_text()
5867
validate(help_text, 100)
5968

clang/docs/tools/dump_format_style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
PLURALS_FILE = os.path.join(os.path.dirname(__file__), "plurals.txt")
2121

2222
plurals: Set[str] = set()
23-
with open(PLURALS_FILE, "a+") as f:
23+
with open(PLURALS_FILE) as f:
2424
f.seek(0)
2525
plurals = set(f.read().splitlines())
2626

clang/include/clang/AST/DeclTemplate.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ class RedeclarableTemplateDecl : public TemplateDecl,
735735
}
736736

737737
void anchor() override;
738+
738739
protected:
739740
template <typename EntryType> struct SpecEntryTraits {
740741
using DeclType = EntryType;
@@ -775,13 +776,22 @@ class RedeclarableTemplateDecl : public TemplateDecl,
775776
return SpecIterator<EntryType>(isEnd ? Specs.end() : Specs.begin());
776777
}
777778

778-
void loadLazySpecializationsImpl() const;
779+
void loadLazySpecializationsImpl(bool OnlyPartial = false) const;
780+
781+
bool loadLazySpecializationsImpl(llvm::ArrayRef<TemplateArgument> Args,
782+
TemplateParameterList *TPL = nullptr) const;
779783

780784
template <class EntryType, typename ...ProfileArguments>
781785
typename SpecEntryTraits<EntryType>::DeclType*
782786
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
783787
void *&InsertPos, ProfileArguments &&...ProfileArgs);
784788

789+
template <class EntryType, typename... ProfileArguments>
790+
typename SpecEntryTraits<EntryType>::DeclType *
791+
findSpecializationLocally(llvm::FoldingSetVector<EntryType> &Specs,
792+
void *&InsertPos,
793+
ProfileArguments &&...ProfileArgs);
794+
785795
template <class Derived, class EntryType>
786796
void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
787797
EntryType *Entry, void *InsertPos);
@@ -796,13 +806,6 @@ class RedeclarableTemplateDecl : public TemplateDecl,
796806
/// was explicitly specialized.
797807
llvm::PointerIntPair<RedeclarableTemplateDecl *, 1, bool>
798808
InstantiatedFromMember;
799-
800-
/// If non-null, points to an array of specializations (including
801-
/// partial specializations) known only by their external declaration IDs.
802-
///
803-
/// The first value in the array is the number of specializations/partial
804-
/// specializations that follow.
805-
GlobalDeclID *LazySpecializations = nullptr;
806809
};
807810

808811
/// Pointer to the common data shared by all declarations of this
@@ -2283,7 +2286,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22832286
friend class TemplateDeclInstantiator;
22842287

22852288
/// Load any lazily-loaded specializations from the external source.
2286-
void LoadLazySpecializations() const;
2289+
void LoadLazySpecializations(bool OnlyPartial = false) const;
22872290

22882291
/// Get the underlying class declarations of the template.
22892292
CXXRecordDecl *getTemplatedDecl() const {
@@ -3033,7 +3036,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
30333036
friend class ASTDeclWriter;
30343037

30353038
/// Load any lazily-loaded specializations from the external source.
3036-
void LoadLazySpecializations() const;
3039+
void LoadLazySpecializations(bool OnlyPartial = false) const;
30373040

30383041
/// Get the underlying variable declarations of the template.
30393042
VarDecl *getTemplatedDecl() const {

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
152152
virtual bool
153153
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
154154

155+
/// Load all the external specializations for the Decl \param D if \param
156+
/// OnlyPartial is false. Otherwise, load all the external **partial**
157+
/// specializations for the \param D.
158+
///
159+
/// Return true if any new specializations get loaded. Return false otherwise.
160+
virtual bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial);
161+
162+
/// Load all the specializations for the Decl \param D with the same template
163+
/// args specified by \param TemplateArgs.
164+
///
165+
/// Return true if any new specializations get loaded. Return false otherwise.
166+
virtual bool
167+
LoadExternalSpecializations(const Decl *D,
168+
ArrayRef<TemplateArgument> TemplateArgs);
169+
155170
/// Ensures that the table of all visible declarations inside this
156171
/// context is up to date.
157172
///

clang/include/clang/Basic/arm_mve.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,13 +1270,13 @@ defm sqrshr: ScalarSaturatingShiftReg<s32, s64>;
12701270
def lsll: LongScalarShift<u64, (args s32:$sh), (IRInt<"lsll"> $lo, $hi, $sh)>;
12711271
def asrl: LongScalarShift<s64, (args s32:$sh), (IRInt<"asrl"> $lo, $hi, $sh)>;
12721272

1273-
multiclass vadcsbc {
1273+
multiclass vadcsbc<dag initial_carry_in> {
12741274
def q: Intrinsic<Vector, (args Vector:$a, Vector:$b, Ptr<uint>:$carry),
12751275
(seq (IRInt<NAME, [Vector]> $a, $b, (shl (load $carry), 29)):$pair,
12761276
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
12771277
(xval $pair, 0))>;
12781278
def iq: Intrinsic<Vector, (args Vector:$a, Vector:$b, Ptr<uint>:$carry),
1279-
(seq (IRInt<NAME, [Vector]> $a, $b, 0):$pair,
1279+
(seq (IRInt<NAME, [Vector]> $a, $b, initial_carry_in):$pair,
12801280
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
12811281
(xval $pair, 0))>;
12821282
def q_m: Intrinsic<Vector, (args Vector:$inactive, Vector:$a, Vector:$b,
@@ -1288,13 +1288,13 @@ multiclass vadcsbc {
12881288
def iq_m: Intrinsic<Vector, (args Vector:$inactive, Vector:$a, Vector:$b,
12891289
Ptr<uint>:$carry, Predicate:$pred),
12901290
(seq (IRInt<NAME # "_predicated", [Vector, Predicate]> $inactive, $a, $b,
1291-
0, $pred):$pair,
1291+
initial_carry_in, $pred):$pair,
12921292
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
12931293
(xval $pair, 0))>;
12941294
}
12951295
let params = T.Int32 in {
1296-
defm vadc: vadcsbc;
1297-
defm vsbc: vadcsbc;
1296+
defm vadc: vadcsbc<(u32 0)>;
1297+
defm vsbc: vadcsbc<(shl 1, 29)>;
12981298
}
12991299

13001300
let params = T.Int in {

clang/include/clang/Sema/MultiplexExternalSemaSource.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
9797
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
9898
DeclarationName Name) override;
9999

100+
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
101+
102+
bool
103+
LoadExternalSpecializations(const Decl *D,
104+
ArrayRef<TemplateArgument> TemplateArgs) override;
105+
100106
/// Ensures that the table of all visible declarations inside this
101107
/// context is up to date.
102108
void completeVisibleDeclsMap(const DeclContext *DC) override;

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,13 @@ enum ASTRecordTypes {
733733
/// Record code for Sema's vector of functions/blocks with effects to
734734
/// be verified.
735735
DECLS_WITH_EFFECTS_TO_VERIFY = 72,
736+
737+
/// Record code for updated specialization
738+
UPDATE_SPECIALIZATION = 73,
739+
740+
CXX_ADDED_TEMPLATE_SPECIALIZATION = 74,
741+
742+
CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION = 75,
736743
};
737744

738745
/// Record types used within a source manager block.
@@ -1502,6 +1509,12 @@ enum DeclCode {
15021509
/// An ImplicitConceptSpecializationDecl record.
15031510
DECL_IMPLICIT_CONCEPT_SPECIALIZATION,
15041511

1512+
// A decls specilization record.
1513+
DECL_SPECIALIZATIONS,
1514+
1515+
// A decls specilization record.
1516+
DECL_PARTIAL_SPECIALIZATIONS,
1517+
15051518
DECL_LAST = DECL_IMPLICIT_CONCEPT_SPECIALIZATION
15061519
};
15071520

clang/include/clang/Serialization/ASTReader.h

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ class ASTIdentifierLookupTrait;
354354
/// The on-disk hash table(s) used for DeclContext name lookup.
355355
struct DeclContextLookupTable;
356356

357+
/// The on-disk hash table(s) used for specialization decls.
358+
struct LazySpecializationInfoLookupTable;
359+
357360
} // namespace reader
358361

359362
} // namespace serialization
@@ -632,20 +635,40 @@ class ASTReader
632635
llvm::DenseMap<const DeclContext *,
633636
serialization::reader::DeclContextLookupTable> Lookups;
634637

638+
using SpecLookupTableTy =
639+
llvm::DenseMap<const Decl *,
640+
serialization::reader::LazySpecializationInfoLookupTable>;
641+
/// Map from decls to specialized decls.
642+
SpecLookupTableTy SpecializationsLookups;
643+
/// Split partial specialization from specialization to speed up lookups.
644+
SpecLookupTableTy PartialSpecializationsLookups;
645+
646+
bool LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
647+
const Decl *D);
648+
bool LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
649+
const Decl *D,
650+
ArrayRef<TemplateArgument> TemplateArgs);
651+
635652
// Updates for visible decls can occur for other contexts than just the
636653
// TU, and when we read those update records, the actual context may not
637654
// be available yet, so have this pending map using the ID as a key. It
638-
// will be realized when the context is actually loaded.
639-
struct PendingVisibleUpdate {
655+
// will be realized when the data is actually loaded.
656+
struct UpdateData {
640657
ModuleFile *Mod;
641658
const unsigned char *Data;
642659
};
643-
using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
660+
using DeclContextVisibleUpdates = SmallVector<UpdateData, 1>;
644661

645662
/// Updates to the visible declarations of declaration contexts that
646663
/// haven't been loaded yet.
647664
llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates> PendingVisibleUpdates;
648665

666+
using SpecializationsUpdate = SmallVector<UpdateData, 1>;
667+
using SpecializationsUpdateMap =
668+
llvm::DenseMap<GlobalDeclID, SpecializationsUpdate>;
669+
SpecializationsUpdateMap PendingSpecializationsUpdates;
670+
SpecializationsUpdateMap PendingPartialSpecializationsUpdates;
671+
649672
/// The set of C++ or Objective-C classes that have forward
650673
/// declarations that have not yet been linked to their definitions.
651674
llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
@@ -678,6 +701,11 @@ class ASTReader
678701
llvm::BitstreamCursor &Cursor,
679702
uint64_t Offset, GlobalDeclID ID);
680703

704+
bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor,
705+
uint64_t Offset, Decl *D, bool IsPartial);
706+
void AddSpecializations(const Decl *D, const unsigned char *Data,
707+
ModuleFile &M, bool IsPartial);
708+
681709
/// A vector containing identifiers that have already been
682710
/// loaded.
683711
///
@@ -1419,6 +1447,14 @@ class ASTReader
14191447
const serialization::reader::DeclContextLookupTable *
14201448
getLoadedLookupTables(DeclContext *Primary) const;
14211449

1450+
/// Get the loaded specializations lookup tables for \p D,
1451+
/// if any.
1452+
serialization::reader::LazySpecializationInfoLookupTable *
1453+
getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial);
1454+
1455+
/// If we have any unloaded specialization for \p D
1456+
bool haveUnloadedSpecializations(const Decl *D) const;
1457+
14221458
private:
14231459
struct ImportedModule {
14241460
ModuleFile *Mod;
@@ -2076,6 +2112,12 @@ class ASTReader
20762112
unsigned BlockID,
20772113
uint64_t *StartOfBlockOffset = nullptr);
20782114

2115+
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
2116+
2117+
bool
2118+
LoadExternalSpecializations(const Decl *D,
2119+
ArrayRef<TemplateArgument> TemplateArgs) override;
2120+
20792121
/// Finds all the visible declarations with a given name.
20802122
/// The current implementation of this method just loads the entire
20812123
/// lookup table as unmaterialized references.

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ class ASTWriter : public ASTDeserializationListener,
423423
/// Only meaningful for reduced BMI.
424424
DeclUpdateMap DeclUpdatesFromGMF;
425425

426+
/// Mapping from decl templates and its new specialization in the
427+
/// current TU.
428+
using SpecializationUpdateMap =
429+
llvm::MapVector<const NamedDecl *, SmallVector<const Decl *>>;
430+
SpecializationUpdateMap SpecializationsUpdates;
431+
SpecializationUpdateMap PartialSpecializationsUpdates;
432+
426433
using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
427434

428435
/// Map of first declarations from a chained PCH that point to the
@@ -575,6 +582,12 @@ class ASTWriter : public ASTDeserializationListener,
575582

576583
bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
577584

585+
void GenerateSpecializationInfoLookupTable(
586+
const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
587+
llvm::SmallVectorImpl<char> &LookupTable, bool IsPartial);
588+
uint64_t WriteSpecializationInfoLookupTable(
589+
const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
590+
bool IsPartial);
578591
void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
579592
llvm::SmallVectorImpl<char> &LookupTable);
580593
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
@@ -590,6 +603,7 @@ class ASTWriter : public ASTDeserializationListener,
590603
void WriteDeclAndTypes(ASTContext &Context);
591604
void PrepareWritingSpecialDecls(Sema &SemaRef);
592605
void WriteSpecialDeclRecords(Sema &SemaRef);
606+
void WriteSpecializationsUpdates(bool IsPartial);
593607
void WriteDeclUpdatesBlocks(ASTContext &Context,
594608
RecordDataImpl &OffsetsRecord);
595609
void WriteDeclContextVisibleUpdate(ASTContext &Context,
@@ -619,6 +633,9 @@ class ASTWriter : public ASTDeserializationListener,
619633
unsigned DeclEnumAbbrev = 0;
620634
unsigned DeclObjCIvarAbbrev = 0;
621635
unsigned DeclCXXMethodAbbrev = 0;
636+
unsigned DeclSpecializationsAbbrev = 0;
637+
unsigned DeclPartialSpecializationsAbbrev = 0;
638+
622639
unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
623640
unsigned DeclTemplateCXXMethodAbbrev = 0;
624641
unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;

0 commit comments

Comments
 (0)