Skip to content

Commit e802dc2

Browse files
authored
merge main into amd-staging (llvm#1640)
2 parents b9c0100 + 2315593 commit e802dc2

File tree

326 files changed

+7008
-4094
lines changed

Some content is hidden

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

326 files changed

+7008
-4094
lines changed

clang-tools-extra/clangd/AST.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ QualType declaredType(const TypeDecl *D) {
439439
if (const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(D))
440440
if (const auto *Args = CTSD->getTemplateArgsAsWritten())
441441
return Context.getTemplateSpecializationType(
442-
TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(),
443-
/*CanonicalArgs=*/std::nullopt);
442+
TemplateName(CTSD->getSpecializedTemplate()), Args->arguments());
444443
return Context.getTypeDeclType(D);
445444
}
446445

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ C23 Feature Support
170170
scope.
171171
- Fixed a bug where you could not cast a null pointer constant to type
172172
``nullptr_t``. Fixes #GH133644.
173+
- Fixed a failed assertion with an invalid parameter to the ``#embed``
174+
directive. Fixes #GH126940.
173175

174176
C11 Feature Support
175177
^^^^^^^^^^^^^^^^^^^
@@ -301,8 +303,6 @@ Improvements to Clang's diagnostics
301303
- Clang now better preserves the sugared types of pointers to member.
302304
- Clang now better preserves the presence of the template keyword with dependent
303305
prefixes.
304-
- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of
305-
the template parameter.
306306
- Clang now respects the current language mode when printing expressions in
307307
diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also
308308
a bunch of HLSL types being printed as their C++ equivalents.
@@ -350,6 +350,7 @@ Improvements to Clang's diagnostics
350350
- Fixed an assertion when referencing an out-of-bounds parameter via a function
351351
attribute whose argument list refers to parameters by index and the function
352352
is variadic. e.g.,
353+
353354
.. code-block:: c
354355
355356
__attribute__ ((__format_arg__(2))) void test (int i, ...) { }

clang/include/clang/AST/ASTContext.h

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
367367
const ASTContext&>
368368
CanonTemplateTemplateParms;
369369

370+
TemplateTemplateParmDecl *
371+
getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
372+
370373
/// The typedef for the __int128_t type.
371374
mutable TypedefDecl *Int128Decl = nullptr;
372375

@@ -1808,26 +1811,22 @@ class ASTContext : public RefCountedBase<ASTContext> {
18081811
bool ParameterPack,
18091812
TemplateTypeParmDecl *ParmDecl = nullptr) const;
18101813

1811-
QualType getCanonicalTemplateSpecializationType(
1812-
TemplateName T, ArrayRef<TemplateArgument> CanonicalArgs) const;
1814+
QualType getTemplateSpecializationType(TemplateName T,
1815+
ArrayRef<TemplateArgument> Args,
1816+
QualType Canon = QualType()) const;
18131817

18141818
QualType
1815-
getTemplateSpecializationType(TemplateName T,
1816-
ArrayRef<TemplateArgument> SpecifiedArgs,
1817-
ArrayRef<TemplateArgument> CanonicalArgs,
1818-
QualType Underlying = QualType()) const;
1819+
getCanonicalTemplateSpecializationType(TemplateName T,
1820+
ArrayRef<TemplateArgument> Args) const;
18191821

1820-
QualType
1821-
getTemplateSpecializationType(TemplateName T,
1822-
ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
1823-
ArrayRef<TemplateArgument> CanonicalArgs,
1824-
QualType Canon = QualType()) const;
1822+
QualType getTemplateSpecializationType(TemplateName T,
1823+
ArrayRef<TemplateArgumentLoc> Args,
1824+
QualType Canon = QualType()) const;
18251825

1826-
TypeSourceInfo *getTemplateSpecializationTypeInfo(
1827-
TemplateName T, SourceLocation TLoc,
1828-
const TemplateArgumentListInfo &SpecifiedArgs,
1829-
ArrayRef<TemplateArgument> CanonicalArgs,
1830-
QualType Canon = QualType()) const;
1826+
TypeSourceInfo *
1827+
getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc,
1828+
const TemplateArgumentListInfo &Args,
1829+
QualType Canon = QualType()) const;
18311830

18321831
QualType getParenType(QualType NamedType) const;
18331832

@@ -2943,21 +2942,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
29432942
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg)
29442943
const;
29452944

2946-
/// Canonicalize the given template argument list.
2947-
///
2948-
/// Returns true if any arguments were non-canonical, false otherwise.
2949-
bool
2950-
canonicalizeTemplateArguments(MutableArrayRef<TemplateArgument> Args) const;
2951-
2952-
/// Canonicalize the given TemplateTemplateParmDecl.
2953-
TemplateTemplateParmDecl *
2954-
getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
2955-
2956-
TemplateTemplateParmDecl *findCanonicalTemplateTemplateParmDeclInternal(
2957-
TemplateTemplateParmDecl *TTP) const;
2958-
TemplateTemplateParmDecl *insertCanonicalTemplateTemplateParmDeclInternal(
2959-
TemplateTemplateParmDecl *CanonTTP) const;
2960-
29612945
/// Type Query functions. If the type is an instance of the specified class,
29622946
/// return the Type pointer for the underlying maximally pretty type. This
29632947
/// is a member of ASTContext because this may need to do some amount of

clang/include/clang/AST/PropertiesBase.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -877,14 +877,11 @@ let Class = PropertyTypeCase<TemplateArgument, "Expression"> in {
877877
def : Property<"expression", ExprRef> {
878878
let Read = [{ node.getAsExpr() }];
879879
}
880-
def : Property<"IsCanonical", Bool> {
881-
let Read = [{ node.isCanonicalExpr() }];
882-
}
883880
def : Property<"isDefaulted", Bool> {
884881
let Read = [{ node.getIsDefaulted() }];
885882
}
886883
def : Creator<[{
887-
return TemplateArgument(expression, IsCanonical, isDefaulted);
884+
return TemplateArgument(expression, isDefaulted);
888885
}]>;
889886
}
890887
let Class = PropertyTypeCase<TemplateArgument, "Pack"> in {

clang/include/clang/AST/TemplateBase.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ class TemplateArgument {
167167
unsigned Kind : 31;
168168
LLVM_PREFERRED_TYPE(bool)
169169
unsigned IsDefaulted : 1;
170-
LLVM_PREFERRED_TYPE(bool)
171-
unsigned IsCanonicalExpr : 1;
172170
uintptr_t V;
173171
};
174172
union {
@@ -189,8 +187,7 @@ class TemplateArgument {
189187

190188
public:
191189
/// Construct an empty, invalid template argument.
192-
constexpr TemplateArgument()
193-
: TypeOrValue{Null, /*IsDefaulted=*/0, /*IsCanonicalExpr=*/0, /*V=*/0} {}
190+
constexpr TemplateArgument() : TypeOrValue({Null, 0, /* IsDefaulted */ 0}) {}
194191

195192
/// Construct a template type argument.
196193
TemplateArgument(QualType T, bool isNullPtr = false,
@@ -265,10 +262,9 @@ class TemplateArgument {
265262
/// This form of template argument only occurs in template argument
266263
/// lists used for dependent types and for expression; it will not
267264
/// occur in a non-dependent, canonical template argument list.
268-
TemplateArgument(Expr *E, bool IsCanonical, bool IsDefaulted = false) {
265+
explicit TemplateArgument(Expr *E, bool IsDefaulted = false) {
269266
TypeOrValue.Kind = Expression;
270267
TypeOrValue.IsDefaulted = IsDefaulted;
271-
TypeOrValue.IsCanonicalExpr = IsCanonical;
272268
TypeOrValue.V = reinterpret_cast<uintptr_t>(E);
273269
}
274270

@@ -411,11 +407,6 @@ class TemplateArgument {
411407
return reinterpret_cast<Expr *>(TypeOrValue.V);
412408
}
413409

414-
bool isCanonicalExpr() const {
415-
assert(getKind() == Expression && "Unexpected kind");
416-
return TypeOrValue.IsCanonicalExpr;
417-
}
418-
419410
/// Iterator that traverses the elements of a template argument pack.
420411
using pack_iterator = const TemplateArgument *;
421412

clang/include/clang/AST/Type.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6676,9 +6676,10 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
66766676
/// replacement must, recursively, be one of these).
66776677
TemplateName Template;
66786678

6679-
TemplateSpecializationType(TemplateName T, bool IsAlias,
6679+
TemplateSpecializationType(TemplateName T,
66806680
ArrayRef<TemplateArgument> Args,
6681-
QualType Underlying);
6681+
QualType Canon,
6682+
QualType Aliased);
66826683

66836684
public:
66846685
/// Determine whether any of the given template arguments are dependent.
@@ -6746,7 +6747,7 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
67466747

67476748
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx);
67486749
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T,
6749-
ArrayRef<TemplateArgument> Args, QualType Underlying,
6750+
ArrayRef<TemplateArgument> Args,
67506751
const ASTContext &Context);
67516752

67526753
static bool classof(const Type *T) {

clang/include/clang/AST/TypeProperties.td

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,19 +737,39 @@ let Class = DependentAddressSpaceType in {
737737
}
738738

739739
let Class = TemplateSpecializationType in {
740+
def : Property<"dependent", Bool> {
741+
let Read = [{ node->isDependentType() }];
742+
}
740743
def : Property<"templateName", TemplateName> {
741744
let Read = [{ node->getTemplateName() }];
742745
}
743-
def : Property<"args", Array<TemplateArgument>> {
746+
def : Property<"templateArguments", Array<TemplateArgument>> {
744747
let Read = [{ node->template_arguments() }];
745748
}
746-
def : Property<"UnderlyingType", QualType> {
747-
let Read = [{ node->isCanonicalUnqualified() ? QualType() :
748-
node->desugar() }];
749+
def : Property<"underlyingType", Optional<QualType>> {
750+
let Read = [{
751+
node->isTypeAlias()
752+
? std::optional<QualType>(node->getAliasedType())
753+
: node->isCanonicalUnqualified()
754+
? std::nullopt
755+
: std::optional<QualType>(node->getCanonicalTypeInternal())
756+
}];
749757
}
750758

751759
def : Creator<[{
752-
return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, UnderlyingType);
760+
QualType result;
761+
if (!underlyingType) {
762+
result = ctx.getCanonicalTemplateSpecializationType(templateName,
763+
templateArguments);
764+
} else {
765+
result = ctx.getTemplateSpecializationType(templateName,
766+
templateArguments,
767+
*underlyingType);
768+
}
769+
if (dependent)
770+
const_cast<Type *>(result.getTypePtr())
771+
->addDependence(TypeDependence::DependentInstantiation);
772+
return result;
753773
}]>;
754774
}
755775

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//===- FixitUtil.h ----------------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_ANALYSIS_SUPPORT_FIXITUTIL_H
10+
#define LLVM_CLANG_ANALYSIS_SUPPORT_FIXITUTIL_H
11+
12+
#include "clang/AST/Decl.h"
13+
#include "clang/AST/Expr.h"
14+
#include "clang/Basic/SourceLocation.h"
15+
#include "clang/Lex/Lexer.h"
16+
#include <optional>
17+
#include <string>
18+
19+
namespace clang {
20+
21+
// Returns the text of the pointee type of `T` from a `VarDecl` of a pointer
22+
// type. The text is obtained through from `TypeLoc`s. Since `TypeLoc` does not
23+
// have source ranges of qualifiers ( The `QualTypeLoc` looks hacky too me
24+
// :( ), `Qualifiers` of the pointee type is returned separately through the
25+
// output parameter `QualifiersToAppend`.
26+
std::optional<std::string>
27+
getPointeeTypeText(const DeclaratorDecl *VD, const SourceManager &SM,
28+
const LangOptions &LangOpts,
29+
std::optional<Qualifiers> *QualifiersToAppend);
30+
31+
// returns text of pointee to pointee (T*&)
32+
std::optional<std::string>
33+
getPointee2TypeText(const DeclaratorDecl *VD, const SourceManager &SM,
34+
const LangOptions &LangOpts,
35+
std::optional<Qualifiers> *QualifiersToAppend);
36+
37+
SourceLocation getBeginLocOfNestedIdentifier(const DeclaratorDecl *D);
38+
39+
// Returns the literal text in `SourceRange SR`, if `SR` is a valid range.
40+
std::optional<StringRef> getRangeText(SourceRange SR, const SourceManager &SM,
41+
const LangOptions &LangOpts);
42+
43+
// Returns the literal text of the identifier of the given variable declaration.
44+
std::optional<StringRef> getVarDeclIdentifierText(const DeclaratorDecl *VD,
45+
const SourceManager &SM,
46+
const LangOptions &LangOpts);
47+
48+
// Return text representation of an `Expr`.
49+
std::optional<StringRef> getExprText(const Expr *E, const SourceManager &SM,
50+
const LangOptions &LangOpts);
51+
52+
// Return the source location just past the last character of the AST `Node`.
53+
template <typename NodeTy>
54+
std::optional<SourceLocation> getPastLoc(const NodeTy *Node,
55+
const SourceManager &SM,
56+
const LangOptions &LangOpts) {
57+
SourceLocation Loc =
58+
Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
59+
if (Loc.isValid())
60+
return Loc;
61+
return std::nullopt;
62+
}
63+
64+
// Returns the begin location of the identifier of the given variable
65+
// declaration.
66+
SourceLocation getVarDeclIdentifierLoc(const DeclaratorDecl *VD);
67+
68+
} // end namespace clang
69+
70+
#endif /* LLVM_CLANG_ANALYSIS_SUPPORT_FIXITUTIL_H */

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,18 @@ TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4bf16, "V4yV4y*1", "nc", "g
511511

512512
TARGET_BUILTIN(__builtin_amdgcn_ds_bpermute_fi_b32, "iii", "nc", "gfx12-insts")
513513

514+
// For the following two builtins, the second and third return values of the
515+
// intrinsics are returned through the last two pointer-type function arguments.
516+
TARGET_BUILTIN(__builtin_amdgcn_image_bvh8_intersect_ray, "V10UiWUifUcV3fV3fUiV4UiV3f*V3f*", "nc", "gfx12-insts")
517+
TARGET_BUILTIN(__builtin_amdgcn_image_bvh_dual_intersect_ray, "V10UiWUifUcV3fV3fV2UiV4UiV3f*V3f*", "nc", "gfx12-insts")
518+
519+
TARGET_BUILTIN(__builtin_amdgcn_ds_bvh_stack_push4_pop1_rtn, "V2UiUiUiV4UiIi", "n", "gfx11-insts")
520+
TARGET_BUILTIN(__builtin_amdgcn_ds_bvh_stack_push8_pop1_rtn, "V2UiUiUiV8UiIi", "n", "gfx12-insts")
521+
522+
// The intrinsic returns {i64, i32}, the builtin returns <2 x i64>.
523+
// The second return value of the intrinsic is zext'ed.
524+
TARGET_BUILTIN(__builtin_amdgcn_ds_bvh_stack_push8_pop2_rtn, "V2WUiUiUiV8UiIi", "n", "gfx12-insts")
525+
514526
//===----------------------------------------------------------------------===//
515527
// WMMA builtins.
516528
// Postfix w32 indicates the builtin requires wavefront size of 32.

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def err_module_file_not_module : Error<
7575
def err_module_file_missing_top_level_submodule : Error<
7676
"module file '%0' is missing its top-level submodule">, DefaultFatal;
7777
def note_module_file_conflict : Note<
78-
"this is generally caused by modules with the same name found in multiple "
79-
"paths">;
78+
"compiled from '%0' and '%1'">;
8079

8180
def remark_module_import : Remark<
8281
"importing module '%0'%select{| into '%3'}2 from '%1'">,

0 commit comments

Comments
 (0)