Skip to content

Commit 1cd8c86

Browse files
authored
Merge pull request #369 from Xilinx/bump_to_ce7c828e
[AutoBump] Merge with ce7c828 (Aug 30) (16)
2 parents 43daff1 + 27fa658 commit 1cd8c86

File tree

450 files changed

+15559
-4077
lines changed

Some content is hidden

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

450 files changed

+15559
-4077
lines changed

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 85 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,87 @@ class FailedPrerequisiteModules : public PrerequisiteModules {
9292
}
9393
};
9494

95+
struct ModuleFile {
96+
ModuleFile(StringRef ModuleName, PathRef ModuleFilePath)
97+
: ModuleName(ModuleName.str()), ModuleFilePath(ModuleFilePath.str()) {}
98+
99+
ModuleFile() = delete;
100+
101+
ModuleFile(const ModuleFile &) = delete;
102+
ModuleFile operator=(const ModuleFile &) = delete;
103+
104+
// The move constructor is needed for llvm::SmallVector.
105+
ModuleFile(ModuleFile &&Other)
106+
: ModuleName(std::move(Other.ModuleName)),
107+
ModuleFilePath(std::move(Other.ModuleFilePath)) {
108+
Other.ModuleName.clear();
109+
Other.ModuleFilePath.clear();
110+
}
111+
112+
ModuleFile &operator=(ModuleFile &&Other) {
113+
if (this == &Other)
114+
return *this;
115+
116+
this->~ModuleFile();
117+
new (this) ModuleFile(std::move(Other));
118+
return *this;
119+
}
120+
121+
~ModuleFile() {
122+
if (!ModuleFilePath.empty())
123+
llvm::sys::fs::remove(ModuleFilePath);
124+
}
125+
126+
std::string ModuleName;
127+
std::string ModuleFilePath;
128+
};
129+
130+
bool IsModuleFileUpToDate(
131+
PathRef ModuleFilePath,
132+
const PrerequisiteModules &RequisiteModules) {
133+
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
134+
CompilerInstance::createDiagnostics(new DiagnosticOptions());
135+
136+
auto HSOpts = std::make_shared<HeaderSearchOptions>();
137+
RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
138+
HSOpts->ForceCheckCXX20ModulesInputFiles = true;
139+
HSOpts->ValidateASTInputFilesContent = true;
140+
141+
PCHContainerOperations PCHOperations;
142+
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
143+
ModuleFilePath.str(), PCHOperations.getRawReader(), ASTUnit::LoadASTOnly,
144+
Diags, FileSystemOptions(), std::move(HSOpts));
145+
146+
if (!Unit)
147+
return false;
148+
149+
auto Reader = Unit->getASTReader();
150+
if (!Reader)
151+
return false;
152+
153+
bool UpToDate = true;
154+
Reader->getModuleManager().visit([&](serialization::ModuleFile &MF) -> bool {
155+
Reader->visitInputFiles(
156+
MF, /*IncludeSystem=*/false, /*Complain=*/false,
157+
[&](const serialization::InputFile &IF, bool isSystem) {
158+
if (!IF.getFile() || IF.isOutOfDate())
159+
UpToDate = false;
160+
});
161+
162+
return !UpToDate;
163+
});
164+
165+
return UpToDate;
166+
}
167+
168+
bool IsModuleFilesUpToDate(
169+
llvm::SmallVector<PathRef> ModuleFilePaths,
170+
const PrerequisiteModules &RequisiteModules) {
171+
return llvm::all_of(ModuleFilePaths, [&RequisiteModules](auto ModuleFilePath) {
172+
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules);
173+
});
174+
}
175+
95176
// StandalonePrerequisiteModules - stands for PrerequisiteModules for which all
96177
// the required modules are built successfully. All the module files
97178
// are owned by the StandalonePrerequisiteModules class.
@@ -135,29 +216,6 @@ class StandalonePrerequisiteModules : public PrerequisiteModules {
135216
}
136217

137218
private:
138-
struct ModuleFile {
139-
ModuleFile(llvm::StringRef ModuleName, PathRef ModuleFilePath)
140-
: ModuleName(ModuleName.str()), ModuleFilePath(ModuleFilePath.str()) {}
141-
142-
ModuleFile(const ModuleFile &) = delete;
143-
ModuleFile operator=(const ModuleFile &) = delete;
144-
145-
// The move constructor is needed for llvm::SmallVector.
146-
ModuleFile(ModuleFile &&Other)
147-
: ModuleName(std::move(Other.ModuleName)),
148-
ModuleFilePath(std::move(Other.ModuleFilePath)) {}
149-
150-
ModuleFile &operator=(ModuleFile &&Other) = delete;
151-
152-
~ModuleFile() {
153-
if (!ModuleFilePath.empty())
154-
llvm::sys::fs::remove(ModuleFilePath);
155-
}
156-
157-
std::string ModuleName;
158-
std::string ModuleFilePath;
159-
};
160-
161219
llvm::SmallVector<ModuleFile, 8> RequiredModules;
162220
// A helper class to speedup the query if a module is built.
163221
llvm::StringSet<> BuiltModuleNames;
@@ -286,50 +344,10 @@ bool StandalonePrerequisiteModules::canReuse(
286344
if (RequiredModules.empty())
287345
return true;
288346

289-
CompilerInstance Clang;
290-
291-
Clang.setInvocation(std::make_shared<CompilerInvocation>(CI));
292-
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
293-
CompilerInstance::createDiagnostics(new DiagnosticOptions());
294-
Clang.setDiagnostics(Diags.get());
295-
296-
FileManager *FM = Clang.createFileManager(VFS);
297-
Clang.createSourceManager(*FM);
298-
299-
if (!Clang.createTarget())
300-
return false;
301-
302-
assert(Clang.getHeaderSearchOptsPtr());
303-
adjustHeaderSearchOptions(Clang.getHeaderSearchOpts());
304-
// Since we don't need to compile the source code actually, the TU kind here
305-
// doesn't matter.
306-
Clang.createPreprocessor(TU_Complete);
307-
Clang.getHeaderSearchOpts().ForceCheckCXX20ModulesInputFiles = true;
308-
Clang.getHeaderSearchOpts().ValidateASTInputFilesContent = true;
309-
310-
// Following the practice of clang's driver to suppres the checking for ODR
311-
// violation in GMF.
312-
// See
313-
// https://clang.llvm.org/docs/StandardCPlusPlusModules.html#object-definition-consistency
314-
// for example.
315-
Clang.getLangOpts().SkipODRCheckInGMF = true;
316-
317-
Clang.createASTReader();
318-
for (auto &RequiredModule : RequiredModules) {
319-
llvm::StringRef BMIPath = RequiredModule.ModuleFilePath;
320-
// FIXME: Loading BMI fully is too heavy considering something cheaply to
321-
// check if we can reuse the BMI.
322-
auto ReadResult =
323-
Clang.getASTReader()->ReadAST(BMIPath, serialization::MK_MainFile,
324-
SourceLocation(), ASTReader::ARR_None);
325-
326-
if (ReadResult != ASTReader::Success) {
327-
elog("Can't reuse {0}: {1}", BMIPath, ReadResult);
328-
return false;
329-
}
330-
}
331-
332-
return true;
347+
SmallVector<StringRef> BMIPaths;
348+
for (auto &MF : RequiredModules)
349+
BMIPaths.push_back(MF.ModuleFilePath);
350+
return IsModuleFilesUpToDate(BMIPaths, *this);
333351
}
334352

335353
} // namespace clangd

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ Bug Fixes in This Version
285285
Bug Fixes to Compiler Builtins
286286
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
287287

288+
- Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)
289+
290+
- Clang now allows pointee types of atomic builtin arguments to be complete template types
291+
that was not instantiated elsewhere.
292+
293+
- ``__noop`` can now be used in a constant expression. (#GH102064)
294+
288295
Bug Fixes to Attribute Support
289296
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
290297

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

330340
Bug Fixes to AST Handling
331341
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang-c/Index.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,8 +2980,9 @@ enum CXTypeKind {
29802980
CXType_Atomic = 177,
29812981
CXType_BTFTagAttributed = 178,
29822982

2983-
// HLSL Intangible Types
2984-
CXType_HLSLResource = 179
2983+
// HLSL Types
2984+
CXType_HLSLResource = 179,
2985+
CXType_HLSLAttributedResource = 180
29852986
};
29862987

29872988
/**

clang/include/clang/AST/ASTContext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
254254
mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
255255
DependentBitIntTypes;
256256
llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
257+
llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;
257258

258259
mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
259260

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

1675+
QualType getHLSLAttributedResourceType(
1676+
QualType Wrapped, QualType Contained,
1677+
const HLSLAttributedResourceType::Attributes &Attrs);
1678+
16741679
QualType
16751680
getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
16761681
unsigned Index,

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ class ASTNodeTraverser
439439
void VisitBTFTagAttributedType(const BTFTagAttributedType *T) {
440440
Visit(T->getWrappedType());
441441
}
442+
void VisitHLSLAttributedResourceType(const HLSLAttributedResourceType *T) {
443+
QualType Contained = T->getContainedType();
444+
if (!Contained.isNull())
445+
Visit(Contained);
446+
}
442447
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *) {}
443448
void
444449
VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T) {

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,9 @@ DEF_TRAVERSE_TYPE(CountAttributedType, {
11461146
DEF_TRAVERSE_TYPE(BTFTagAttributedType,
11471147
{ TRY_TO(TraverseType(T->getWrappedType())); })
11481148

1149+
DEF_TRAVERSE_TYPE(HLSLAttributedResourceType,
1150+
{ TRY_TO(TraverseType(T->getWrappedType())); })
1151+
11491152
DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
11501153

11511154
DEF_TRAVERSE_TYPE(MacroQualifiedType,
@@ -1445,6 +1448,9 @@ DEF_TRAVERSE_TYPELOC(CountAttributedType,
14451448
DEF_TRAVERSE_TYPELOC(BTFTagAttributedType,
14461449
{ TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
14471450

1451+
DEF_TRAVERSE_TYPELOC(HLSLAttributedResourceType,
1452+
{ TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
1453+
14481454
DEF_TRAVERSE_TYPELOC(ElaboratedType, {
14491455
if (TL.getQualifierLoc()) {
14501456
TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));

clang/include/clang/AST/Type.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "llvm/ADT/iterator_range.h"
4545
#include "llvm/Support/Casting.h"
4646
#include "llvm/Support/Compiler.h"
47+
#include "llvm/Support/DXILABI.h"
4748
#include "llvm/Support/ErrorHandling.h"
4849
#include "llvm/Support/PointerLikeTypeTraits.h"
4950
#include "llvm/Support/TrailingObjects.h"
@@ -6156,6 +6157,54 @@ class BTFTagAttributedType : public Type, public llvm::FoldingSetNode {
61566157
}
61576158
};
61586159

6160+
class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
6161+
public:
6162+
struct Attributes {
6163+
// Data gathered from HLSL resource attributes
6164+
llvm::dxil::ResourceClass ResourceClass;
6165+
uint8_t IsROV : 1;
6166+
Attributes(llvm::dxil::ResourceClass ResourceClass, bool IsROV)
6167+
: ResourceClass(ResourceClass), IsROV(IsROV) {}
6168+
Attributes() : ResourceClass(llvm::dxil::ResourceClass::UAV), IsROV(0) {}
6169+
};
6170+
6171+
private:
6172+
friend class ASTContext; // ASTContext creates these
6173+
6174+
QualType WrappedType;
6175+
QualType ContainedType;
6176+
const Attributes Attrs;
6177+
6178+
HLSLAttributedResourceType(QualType Canon, QualType Wrapped,
6179+
QualType Contained, const Attributes &Attrs)
6180+
: Type(HLSLAttributedResource, Canon, Wrapped->getDependence()),
6181+
WrappedType(Wrapped), ContainedType(Contained), Attrs(Attrs) {}
6182+
6183+
public:
6184+
QualType getWrappedType() const { return WrappedType; }
6185+
QualType getContainedType() const { return ContainedType; }
6186+
const Attributes &getAttrs() const { return Attrs; }
6187+
6188+
bool isSugared() const { return true; }
6189+
QualType desugar() const { return getWrappedType(); }
6190+
6191+
void Profile(llvm::FoldingSetNodeID &ID) {
6192+
Profile(ID, WrappedType, ContainedType, Attrs);
6193+
}
6194+
6195+
static void Profile(llvm::FoldingSetNodeID &ID, QualType Wrapped,
6196+
QualType Contained, const Attributes &Attrs) {
6197+
ID.AddPointer(Wrapped.getAsOpaquePtr());
6198+
ID.AddPointer(Contained.getAsOpaquePtr());
6199+
ID.AddInteger(static_cast<uint32_t>(Attrs.ResourceClass));
6200+
ID.AddBoolean(Attrs.IsROV);
6201+
}
6202+
6203+
static bool classof(const Type *T) {
6204+
return T->getTypeClass() == HLSLAttributedResource;
6205+
}
6206+
};
6207+
61596208
class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
61606209
friend class ASTContext; // ASTContext creates these
61616210

@@ -8579,6 +8628,8 @@ template <typename T> const T *Type::getAsAdjusted() const {
85798628
Ty = A->getModifiedType().getTypePtr();
85808629
else if (const auto *A = dyn_cast<BTFTagAttributedType>(Ty))
85818630
Ty = A->getWrappedType().getTypePtr();
8631+
else if (const auto *A = dyn_cast<HLSLAttributedResourceType>(Ty))
8632+
Ty = A->getWrappedType().getTypePtr();
85828633
else if (const auto *E = dyn_cast<ElaboratedType>(Ty))
85838634
Ty = E->desugar().getTypePtr();
85848635
else if (const auto *P = dyn_cast<ParenType>(Ty))

clang/include/clang/AST/TypeLoc.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,25 @@ class BTFTagAttributedTypeLoc
940940
QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
941941
};
942942

943+
struct HLSLAttributedResourceLocInfo {
944+
SourceRange Range;
945+
};
946+
947+
/// Type source information for HLSL attributed resource type.
948+
class HLSLAttributedResourceTypeLoc
949+
: public ConcreteTypeLoc<UnqualTypeLoc, HLSLAttributedResourceTypeLoc,
950+
HLSLAttributedResourceType,
951+
HLSLAttributedResourceLocInfo> {
952+
public:
953+
TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); }
954+
void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; }
955+
SourceRange getLocalSourceRange() const { return getLocalData()->Range; }
956+
void initializeLocal(ASTContext &Context, SourceLocation loc) {
957+
setSourceRange(SourceRange());
958+
}
959+
QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
960+
};
961+
943962
struct ObjCObjectTypeLocInfo {
944963
SourceLocation TypeArgsLAngleLoc;
945964
SourceLocation TypeArgsRAngleLoc;
@@ -2690,6 +2709,8 @@ inline T TypeLoc::getAsAdjusted() const {
26902709
Cur = ATL.getModifiedLoc();
26912710
else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
26922711
Cur = ATL.getWrappedLoc();
2712+
else if (auto ATL = Cur.getAs<HLSLAttributedResourceTypeLoc>())
2713+
Cur = ATL.getWrappedLoc();
26932714
else if (auto ETL = Cur.getAs<ElaboratedTypeLoc>())
26942715
Cur = ETL.getNamedTypeLoc();
26952716
else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())

clang/include/clang/AST/TypeProperties.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,25 @@ let Class = BTFTagAttributedType in {
687687
}]>;
688688
}
689689

690+
let Class = HLSLAttributedResourceType in {
691+
def : Property<"resClass", UInt32> {
692+
let Read = [{ static_cast<uint32_t>(node->getAttrs().ResourceClass) }];
693+
}
694+
def : Property<"isROV", Bool> {
695+
let Read = [{ node->getAttrs().IsROV }];
696+
}
697+
def : Property<"wrappedTy", QualType> {
698+
let Read = [{ node->getWrappedType() }];
699+
}
700+
def : Property<"containedTy", QualType> {
701+
let Read = [{ node->getContainedType() }];
702+
}
703+
def : Creator<[{
704+
HLSLAttributedResourceType::Attributes attrs(static_cast<llvm::dxil::ResourceClass>(resClass), isROV);
705+
return ctx.getHLSLAttributedResourceType(wrappedTy, containedTy, attrs);
706+
}]>;
707+
}
708+
690709
let Class = DependentAddressSpaceType in {
691710
def : Property<"pointeeType", QualType> {
692711
let Read = [{ node->getPointeeType() }];

0 commit comments

Comments
 (0)