Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoBump] Merge with ce7c828e (Aug 30) (16) #369

Open
wants to merge 92 commits into
base: bump_to_fc110202
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
025f03f
[libc++][NFC] Remove unused struct in <string> (#106527)
philnik777 Aug 29, 2024
a705e8c
[libc++][NFC] Remove __constexpr_is{nan,finite} (#106205)
philnik777 Aug 29, 2024
032c328
[NFC][TableGen] Refactor IntrinsicEmitter code (#106479)
jurahul Aug 29, 2024
4ee2ad2
AArch64: Add tests for atomicrmw fp operations (#103701)
arsenm Aug 29, 2024
5048fab
[Support] Delete FormatVariadicTest Validate sub-test (#106570)
jurahul Aug 29, 2024
26c3a84
AArch64: Use consistent atomicrmw expansion for FP operations (#103702)
arsenm Aug 29, 2024
b5a1b45
[SLP] Early return in getReorderingData [nfc]
preames Aug 29, 2024
a9ffb71
[RISCV] Don't promote f16 FNEG/FABS with Zfhmin/Zhinxmin. (#106474)
topperc Aug 29, 2024
e05c224
AArch64: Delete tests of fp128 atomicrmw fmin/fmax
arsenm Aug 29, 2024
c08c6a7
[mlir][scf] Allow unrolling loops with integer-typed IV. (#106164)
htyu Aug 29, 2024
115b876
[NFC][Support] Eliminate ',' at end of MemoryEffects print (#106545)
jurahul Aug 29, 2024
81acc84
[LoopVectorize][X86] amdlibm-calls.ll - add 2/4/8/16 vector widths te…
RKSimon Aug 29, 2024
a777a93
Fix MSVC "not all control paths return a value" warning. NFC.
RKSimon Aug 29, 2024
bd6531b
[LTO] Introduce a new class ImportIDTable (#106503)
kazutakahirata Aug 29, 2024
59f05b6
[RISCV][TTI] Model cost for insert/extract into illegal types (#106440)
preames Aug 29, 2024
e5e38dd
[AArch64] Make apple-m4 armv8.7-a again (from armv9.2-a). (#106312)
ahmedbougacha Aug 29, 2024
3d08ade
[ExtendLifetimes] Implement llvm.fake.use to extend variable lifetime…
SLTozer Aug 29, 2024
74b4ec1
[VP] Remove VP_PROPERTY_REDUCTION and VP_PROPERTY_CMP [nfc] (#105551)
preames Aug 29, 2024
eed135f
Revert "[Analysis] Guard logf128 cst folding"
RoboTux Aug 29, 2024
1783924
[llvm-lit] Print environment variables when using env without subcomm…
Harini0924 Aug 29, 2024
2dc3b50
[HLSL] Apply NoRecurse attrib to all HLSL functions (#105907)
pow2clk Aug 29, 2024
ecd65e6
[DXIL][test] Fix a few tests now that HLSL functions are internalized…
bogner Aug 29, 2024
2ad782f
[VP] Kill VP_PROPERTY_(MEMOP,CASTOP) and simplify _CONSTRAINEDFP [nfc…
preames Aug 29, 2024
0a00d32
[lldb] Add armv7a and armv8a ArchSpecs (#106433)
ajordanr-google Aug 29, 2024
ed37b5f
Revert "[Support] Validate number of arguments passed to formatv()" (…
joker-eph Aug 29, 2024
67ffd14
libcxx: [NFC] relax error expectation for clang diagnostics (#106591)
mizvekov Aug 29, 2024
9ce4af5
Revert "Revert "[Support] Validate number of arguments passed to form…
jurahul Aug 29, 2024
9a58b12
[ExtendLifetimes][NFC] Add explicit triple to new fake-use tests
SLTozer Aug 29, 2024
4bc7c74
[SLP] Extract isIdentityOrder to common routine [probably NFC] (#106582)
preames Aug 29, 2024
fd0dbc7
[DirectX] add enum for PSV resource type/kind/flag. (#106227)
python3kgae Aug 29, 2024
1ace91f
[libc][math] Add performance tests for fmul and fmull. (#106262)
Aug 29, 2024
0a41c8e
[flang][cuda] Avoid generating cuf.data_transfer in OpenACC region (#…
clementval Aug 29, 2024
6421dcc
[NFC] [DSE] Refactor DSE (#100956)
haopliu Aug 29, 2024
22ba351
[RISCV][SLP] Test for <3 x Ty> reductions which require reordering
preames Aug 29, 2024
26b0bef
AMDGPU: Use pattern to select instruction for intrinsic llvm.fptrunc.…
changpeng Aug 29, 2024
c1248c9
[Clang] prevent assertion failure when converting vectors to int/floa…
a-tarasyuk Aug 29, 2024
e9eaf19
[CodeGen] Allow mixed scalar type constraints for inline asm (#65465)
dfszabo Aug 29, 2024
ff04c5b
[NFC][Sema] Move `Sema::AssignmentAction` into its own scoped enum (#…
delcypher Aug 29, 2024
a0441ce
[NFC] whitespace cleanup on clang/test/SemaTemplate/temp_arg_nontype.cpp
mizvekov Aug 29, 2024
a871051
[libc] Implement locale variants for 'stdlib.h' functions (#105718)
jhuber6 Aug 29, 2024
5c019bd
[libc] Add support for 'string.h' locale variants (#105719)
jhuber6 Aug 29, 2024
ba5e8fc
[flang] Adjust execute_command_line intrinsic return values for AIX (…
kkwli Aug 29, 2024
74938ab
[AMDGPU][True16][MC] add true16/fake16 flag to gfx12 dasm tests (#106…
broxigarchen Aug 29, 2024
59762a0
[RISCV] Add coverage for <3 x float> reduction with neutral start
preames Aug 29, 2024
d5c292d
[GISel][RISCV] Correctly handle scalable vector shuffles of pointer v…
topperc Aug 29, 2024
aeedab7
[SLP]Correctly decide if the non-power-of-2 number of stores can be v…
alexey-bataev Aug 29, 2024
f08f9cd
[HWASan] remove incorrectly inferred attributes (#106565)
fmayer Aug 29, 2024
0141a3c
[analyzer] Fix nullptr dereference for symbols from pointer invalidat…
necto Aug 29, 2024
66927fb
Revert "[HWASan] remove incorrectly inferred attributes" (#106622)
fmayer Aug 29, 2024
c490658
[VPlan] Use skipCostComputation when pre-computing induction costs.
fhahn Aug 29, 2024
1f0d545
[libc++] Fix wraparound issue with -fsanitize=integer in string opera…
ldionne Aug 29, 2024
049b60c
[NFC][Clang] Avoid potential null pointer dereferences in Sema::AddIn…
tahonermann Aug 29, 2024
593526f
[X86] Use MCRegister instead of int64_t in X86MCExpr. NFC (#106569)
topperc Aug 29, 2024
4ca817d
[GlobalISel] Add bail outs for scalable vectors to some combines. (#1…
topperc Aug 29, 2024
1827086
[SandboxIR] Add ExtractValueInst. (#106613)
slackito Aug 29, 2024
412e3e3
[ExtendLifetimes][NFC] Add explicit triple to remaining fake-use tests
SLTozer Aug 29, 2024
7284e0f
[clang] mangle placeholder for deduced type as a template-prefix (#10…
mizvekov Aug 29, 2024
4caf019
[clang][test] Rewrote test using command substitution to work with li…
connieyzhu Aug 29, 2024
aa91d90
[LegalizeVectorOps][PowerPC] Use xor to expand fneg. (#106595)
topperc Aug 29, 2024
e51fc36
[lsan][test] Allow testcase to execute on remote targets without not …
rjmansfield Aug 29, 2024
cc943a6
[SLP]Fix PR106626: trye several attempts for lookup values, if not fo…
alexey-bataev Aug 29, 2024
a1441ca
[flang][Driver] Add support for -mllvm -print-pipeline-passes
tarunprabhu Aug 29, 2024
dac1f7b
[NVPTX] fixup incorrect rounding mode for int to float conversion (#1…
AlexMaclean Aug 29, 2024
ec68dc1
[compiler-rt] Work around incompatible Windows definitions of (S)SIZE_T
arichardson Aug 29, 2024
9df92cb
[compiler-rt] Remove duplicates of sanitizer_common functions
arichardson Aug 29, 2024
dbbfc95
[RISCV] Separate ActiveElementsAffectResult into VL and Mask flags (#…
lukel97 Aug 29, 2024
034f2b3
[SandboxIR] Implement SandboxIR Type (#106294)
vporpo Aug 30, 2024
46fe36a
Revert "[compiler-rt] Remove duplicates of sanitizer_common functions"
arichardson Aug 30, 2024
cdaebf6
[NVPTX] Fix crash caused by ComputePTXValueVTs (#104524)
justinfargnoli Aug 30, 2024
1991aa6
Reapply "[nfc][mlgo] Incrementally update DominatorTreeAnalysis in Fu…
mtrofin Aug 30, 2024
7579787
[clang-format] Correctly identify token-pasted record names (#106484)
owenca Aug 30, 2024
e29c5f3
[RISCV][TTI] Add legality check of vector of address for gather/scatt…
ElvisWang123 Aug 30, 2024
12b0257
Reapply "[HWASan] remove incorrectly inferred attributes" (#106622) (…
fmayer Aug 30, 2024
ca2351d
[C++20] [Modules] Skip checking ODR for merged context in GMF
ChuanqiXu9 Aug 30, 2024
ddaf2e2
[HWASan] add OptimizationRemark for alloca safety (#105872)
fmayer Aug 30, 2024
e004566
[NVPTX][AA] Traverse use-def chain to find non-generic addrspace (#10…
AlexMaclean Aug 30, 2024
e00e9a3
[HLSL] Add HLSLAttributedResourceType (#106181)
hekota Aug 30, 2024
d4c519e
[flang][cuda] Do inline allocation/deallocation in device code (#106628)
clementval Aug 30, 2024
24e791b
[ARM] Use MCRegister instead of unsigned for RegisterReqs in ARMAsmPa…
topperc Aug 30, 2024
b65fc7e
[flang][fir] allow fir.convert from and to !llvm.ptr type (#106590)
jeanPerier Aug 30, 2024
a527248
[flang][acc] allow and ignore DIR between ACC and loops (#106522)
jeanPerier Aug 30, 2024
448d8fa
[NFC] [clangd] [Modules] Extract ModuleFile class and IsModuleFileUpT…
ChuanqiXu9 Aug 30, 2024
cd634f5
[compiler-rt][AArch64][Android] Use getauxval on Android. (#102979)
DanielKristofKiss Aug 30, 2024
d68059b
[NFC] [clangd] [Modules] Change the argument type of IsModuleFileUpTo…
ChuanqiXu9 Aug 30, 2024
8ca6401
[flang][openacc] parse and ignore non-standard shortloop clause (#106…
jeanPerier Aug 30, 2024
89e6a28
[NFC] Add explicit #include llvm-config.h where its macros are used. …
dfukalov Aug 30, 2024
d6ad551
[IPSCCP] Infer nonnull return attribute (#106553)
nikic Aug 30, 2024
e0fa2f1
`__noop` not marked as constexpr #102064 (#105983)
ofAlpaca Aug 30, 2024
1693d8e
[AArch64][SelectionDAG] Vector splitting and promotion for histogram …
DevM-uk Aug 30, 2024
d2b8969
[EdgeBundles] Correct MBB label name in output graph when `-view-edge…
bzEq Aug 30, 2024
ce7c828
[lldb][AArch64] Do not crash if NT_ARM_TLS is missing (#106478)
igorkudrin Aug 30, 2024
27fa658
[AutoBump] Merge with ce7c828e (Aug 30)
mgehre-amd Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
152 changes: 85 additions & 67 deletions clang-tools-extra/clangd/ModulesBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,87 @@ class FailedPrerequisiteModules : public PrerequisiteModules {
}
};

struct ModuleFile {
ModuleFile(StringRef ModuleName, PathRef ModuleFilePath)
: ModuleName(ModuleName.str()), ModuleFilePath(ModuleFilePath.str()) {}

ModuleFile() = delete;

ModuleFile(const ModuleFile &) = delete;
ModuleFile operator=(const ModuleFile &) = delete;

// The move constructor is needed for llvm::SmallVector.
ModuleFile(ModuleFile &&Other)
: ModuleName(std::move(Other.ModuleName)),
ModuleFilePath(std::move(Other.ModuleFilePath)) {
Other.ModuleName.clear();
Other.ModuleFilePath.clear();
}

ModuleFile &operator=(ModuleFile &&Other) {
if (this == &Other)
return *this;

this->~ModuleFile();
new (this) ModuleFile(std::move(Other));
return *this;
}

~ModuleFile() {
if (!ModuleFilePath.empty())
llvm::sys::fs::remove(ModuleFilePath);
}

std::string ModuleName;
std::string ModuleFilePath;
};

bool IsModuleFileUpToDate(
PathRef ModuleFilePath,
const PrerequisiteModules &RequisiteModules) {
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(new DiagnosticOptions());

auto HSOpts = std::make_shared<HeaderSearchOptions>();
RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
HSOpts->ForceCheckCXX20ModulesInputFiles = true;
HSOpts->ValidateASTInputFilesContent = true;

PCHContainerOperations PCHOperations;
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
ModuleFilePath.str(), PCHOperations.getRawReader(), ASTUnit::LoadASTOnly,
Diags, FileSystemOptions(), std::move(HSOpts));

if (!Unit)
return false;

auto Reader = Unit->getASTReader();
if (!Reader)
return false;

bool UpToDate = true;
Reader->getModuleManager().visit([&](serialization::ModuleFile &MF) -> bool {
Reader->visitInputFiles(
MF, /*IncludeSystem=*/false, /*Complain=*/false,
[&](const serialization::InputFile &IF, bool isSystem) {
if (!IF.getFile() || IF.isOutOfDate())
UpToDate = false;
});

return !UpToDate;
});

return UpToDate;
}

bool IsModuleFilesUpToDate(
llvm::SmallVector<PathRef> ModuleFilePaths,
const PrerequisiteModules &RequisiteModules) {
return llvm::all_of(ModuleFilePaths, [&RequisiteModules](auto ModuleFilePath) {
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules);
});
}

// StandalonePrerequisiteModules - stands for PrerequisiteModules for which all
// the required modules are built successfully. All the module files
// are owned by the StandalonePrerequisiteModules class.
Expand Down Expand Up @@ -135,29 +216,6 @@ class StandalonePrerequisiteModules : public PrerequisiteModules {
}

private:
struct ModuleFile {
ModuleFile(llvm::StringRef ModuleName, PathRef ModuleFilePath)
: ModuleName(ModuleName.str()), ModuleFilePath(ModuleFilePath.str()) {}

ModuleFile(const ModuleFile &) = delete;
ModuleFile operator=(const ModuleFile &) = delete;

// The move constructor is needed for llvm::SmallVector.
ModuleFile(ModuleFile &&Other)
: ModuleName(std::move(Other.ModuleName)),
ModuleFilePath(std::move(Other.ModuleFilePath)) {}

ModuleFile &operator=(ModuleFile &&Other) = delete;

~ModuleFile() {
if (!ModuleFilePath.empty())
llvm::sys::fs::remove(ModuleFilePath);
}

std::string ModuleName;
std::string ModuleFilePath;
};

llvm::SmallVector<ModuleFile, 8> RequiredModules;
// A helper class to speedup the query if a module is built.
llvm::StringSet<> BuiltModuleNames;
Expand Down Expand Up @@ -286,50 +344,10 @@ bool StandalonePrerequisiteModules::canReuse(
if (RequiredModules.empty())
return true;

CompilerInstance Clang;

Clang.setInvocation(std::make_shared<CompilerInvocation>(CI));
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(new DiagnosticOptions());
Clang.setDiagnostics(Diags.get());

FileManager *FM = Clang.createFileManager(VFS);
Clang.createSourceManager(*FM);

if (!Clang.createTarget())
return false;

assert(Clang.getHeaderSearchOptsPtr());
adjustHeaderSearchOptions(Clang.getHeaderSearchOpts());
// Since we don't need to compile the source code actually, the TU kind here
// doesn't matter.
Clang.createPreprocessor(TU_Complete);
Clang.getHeaderSearchOpts().ForceCheckCXX20ModulesInputFiles = true;
Clang.getHeaderSearchOpts().ValidateASTInputFilesContent = true;

// Following the practice of clang's driver to suppres the checking for ODR
// violation in GMF.
// See
// https://clang.llvm.org/docs/StandardCPlusPlusModules.html#object-definition-consistency
// for example.
Clang.getLangOpts().SkipODRCheckInGMF = true;

Clang.createASTReader();
for (auto &RequiredModule : RequiredModules) {
llvm::StringRef BMIPath = RequiredModule.ModuleFilePath;
// FIXME: Loading BMI fully is too heavy considering something cheaply to
// check if we can reuse the BMI.
auto ReadResult =
Clang.getASTReader()->ReadAST(BMIPath, serialization::MK_MainFile,
SourceLocation(), ASTReader::ARR_None);

if (ReadResult != ASTReader::Success) {
elog("Can't reuse {0}: {1}", BMIPath, ReadResult);
return false;
}
}

return true;
SmallVector<StringRef> BMIPaths;
for (auto &MF : RequiredModules)
BMIPaths.push_back(MF.ModuleFilePath);
return IsModuleFilesUpToDate(BMIPaths, *this);
}

} // namespace clangd
Expand Down
10 changes: 10 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ Bug Fixes in This Version
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)

- Clang now allows pointee types of atomic builtin arguments to be complete template types
that was not instantiated elsewhere.

- ``__noop`` can now be used in a constant expression. (#GH102064)

Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -326,6 +333,9 @@ Bug Fixes to C++ Support
- Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
- Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558)
- Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813)
- Mangle placeholders for deduced types as a template-prefix, such that mangling
of template template parameters uses the correct production. (#GH106182)
- Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 3 additions & 2 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -2980,8 +2980,9 @@ enum CXTypeKind {
CXType_Atomic = 177,
CXType_BTFTagAttributed = 178,

// HLSL Intangible Types
CXType_HLSLResource = 179
// HLSL Types
CXType_HLSLResource = 179,
CXType_HLSLAttributedResource = 180
};

/**
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
DependentBitIntTypes;
llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;

mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;

Expand Down Expand Up @@ -1671,6 +1672,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped);

QualType getHLSLAttributedResourceType(
QualType Wrapped, QualType Contained,
const HLSLAttributedResourceType::Attributes &Attrs);

QualType
getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
unsigned Index,
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/AST/ASTNodeTraverser.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ class ASTNodeTraverser
void VisitBTFTagAttributedType(const BTFTagAttributedType *T) {
Visit(T->getWrappedType());
}
void VisitHLSLAttributedResourceType(const HLSLAttributedResourceType *T) {
QualType Contained = T->getContainedType();
if (!Contained.isNull())
Visit(Contained);
}
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *) {}
void
VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T) {
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,9 @@ DEF_TRAVERSE_TYPE(CountAttributedType, {
DEF_TRAVERSE_TYPE(BTFTagAttributedType,
{ TRY_TO(TraverseType(T->getWrappedType())); })

DEF_TRAVERSE_TYPE(HLSLAttributedResourceType,
{ TRY_TO(TraverseType(T->getWrappedType())); })

DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })

DEF_TRAVERSE_TYPE(MacroQualifiedType,
Expand Down Expand Up @@ -1445,6 +1448,9 @@ DEF_TRAVERSE_TYPELOC(CountAttributedType,
DEF_TRAVERSE_TYPELOC(BTFTagAttributedType,
{ TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })

DEF_TRAVERSE_TYPELOC(HLSLAttributedResourceType,
{ TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })

DEF_TRAVERSE_TYPELOC(ElaboratedType, {
if (TL.getQualifierLoc()) {
TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
Expand Down
51 changes: 51 additions & 0 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
#include "llvm/Support/TrailingObjects.h"
Expand Down Expand Up @@ -6156,6 +6157,54 @@ class BTFTagAttributedType : public Type, public llvm::FoldingSetNode {
}
};

class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
public:
struct Attributes {
// Data gathered from HLSL resource attributes
llvm::dxil::ResourceClass ResourceClass;
uint8_t IsROV : 1;
Attributes(llvm::dxil::ResourceClass ResourceClass, bool IsROV)
: ResourceClass(ResourceClass), IsROV(IsROV) {}
Attributes() : ResourceClass(llvm::dxil::ResourceClass::UAV), IsROV(0) {}
};

private:
friend class ASTContext; // ASTContext creates these

QualType WrappedType;
QualType ContainedType;
const Attributes Attrs;

HLSLAttributedResourceType(QualType Canon, QualType Wrapped,
QualType Contained, const Attributes &Attrs)
: Type(HLSLAttributedResource, Canon, Wrapped->getDependence()),
WrappedType(Wrapped), ContainedType(Contained), Attrs(Attrs) {}

public:
QualType getWrappedType() const { return WrappedType; }
QualType getContainedType() const { return ContainedType; }
const Attributes &getAttrs() const { return Attrs; }

bool isSugared() const { return true; }
QualType desugar() const { return getWrappedType(); }

void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, WrappedType, ContainedType, Attrs);
}

static void Profile(llvm::FoldingSetNodeID &ID, QualType Wrapped,
QualType Contained, const Attributes &Attrs) {
ID.AddPointer(Wrapped.getAsOpaquePtr());
ID.AddPointer(Contained.getAsOpaquePtr());
ID.AddInteger(static_cast<uint32_t>(Attrs.ResourceClass));
ID.AddBoolean(Attrs.IsROV);
}

static bool classof(const Type *T) {
return T->getTypeClass() == HLSLAttributedResource;
}
};

class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
friend class ASTContext; // ASTContext creates these

Expand Down Expand Up @@ -8579,6 +8628,8 @@ template <typename T> const T *Type::getAsAdjusted() const {
Ty = A->getModifiedType().getTypePtr();
else if (const auto *A = dyn_cast<BTFTagAttributedType>(Ty))
Ty = A->getWrappedType().getTypePtr();
else if (const auto *A = dyn_cast<HLSLAttributedResourceType>(Ty))
Ty = A->getWrappedType().getTypePtr();
else if (const auto *E = dyn_cast<ElaboratedType>(Ty))
Ty = E->desugar().getTypePtr();
else if (const auto *P = dyn_cast<ParenType>(Ty))
Expand Down
21 changes: 21 additions & 0 deletions clang/include/clang/AST/TypeLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,25 @@ class BTFTagAttributedTypeLoc
QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
};

struct HLSLAttributedResourceLocInfo {
SourceRange Range;
};

/// Type source information for HLSL attributed resource type.
class HLSLAttributedResourceTypeLoc
: public ConcreteTypeLoc<UnqualTypeLoc, HLSLAttributedResourceTypeLoc,
HLSLAttributedResourceType,
HLSLAttributedResourceLocInfo> {
public:
TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); }
void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; }
SourceRange getLocalSourceRange() const { return getLocalData()->Range; }
void initializeLocal(ASTContext &Context, SourceLocation loc) {
setSourceRange(SourceRange());
}
QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
};

struct ObjCObjectTypeLocInfo {
SourceLocation TypeArgsLAngleLoc;
SourceLocation TypeArgsRAngleLoc;
Expand Down Expand Up @@ -2690,6 +2709,8 @@ inline T TypeLoc::getAsAdjusted() const {
Cur = ATL.getModifiedLoc();
else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
Cur = ATL.getWrappedLoc();
else if (auto ATL = Cur.getAs<HLSLAttributedResourceTypeLoc>())
Cur = ATL.getWrappedLoc();
else if (auto ETL = Cur.getAs<ElaboratedTypeLoc>())
Cur = ETL.getNamedTypeLoc();
else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
Expand Down
19 changes: 19 additions & 0 deletions clang/include/clang/AST/TypeProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,25 @@ let Class = BTFTagAttributedType in {
}]>;
}

let Class = HLSLAttributedResourceType in {
def : Property<"resClass", UInt32> {
let Read = [{ static_cast<uint32_t>(node->getAttrs().ResourceClass) }];
}
def : Property<"isROV", Bool> {
let Read = [{ node->getAttrs().IsROV }];
}
def : Property<"wrappedTy", QualType> {
let Read = [{ node->getWrappedType() }];
}
def : Property<"containedTy", QualType> {
let Read = [{ node->getContainedType() }];
}
def : Creator<[{
HLSLAttributedResourceType::Attributes attrs(static_cast<llvm::dxil::ResourceClass>(resClass), isROV);
return ctx.getHLSLAttributedResourceType(wrappedTy, containedTy, attrs);
}]>;
}

let Class = DependentAddressSpaceType in {
def : Property<"pointeeType", QualType> {
let Read = [{ node->getPointeeType() }];
Expand Down
Loading