@@ -1948,17 +1948,13 @@ class StringLiteral final
19481948// / [C99 6.4.2.2] - A predefined identifier such as __func__.
19491949class PredefinedExpr final
19501950 : public Expr,
1951- private llvm::TrailingObjects<PredefinedExpr, Stmt *, Expr *,
1952- TypeSourceInfo *> {
1951+ private llvm::TrailingObjects<PredefinedExpr, Stmt *> {
19531952 friend class ASTStmtReader ;
19541953 friend TrailingObjects;
19551954
19561955 // PredefinedExpr is optionally followed by a single trailing
19571956 // "Stmt *" for the predefined identifier. It is present if and only if
19581957 // hasFunctionName() is true and is always a "StringLiteral *".
1959- // It can also be followed by a Expr* in the case of a
1960- // __builtin_unique_stable_name with an expression, or TypeSourceInfo * if
1961- // __builtin_unique_stable_name with a type.
19621958
19631959public:
19641960 enum IdentKind {
@@ -1971,18 +1967,12 @@ class PredefinedExpr final
19711967 PrettyFunction,
19721968 // / The same as PrettyFunction, except that the
19731969 // / 'virtual' keyword is omitted for virtual member functions.
1974- PrettyFunctionNoVirtual,
1975- UniqueStableNameType,
1976- UniqueStableNameExpr,
1970+ PrettyFunctionNoVirtual
19771971 };
19781972
19791973private:
19801974 PredefinedExpr (SourceLocation L, QualType FNTy, IdentKind IK,
19811975 StringLiteral *SL);
1982- PredefinedExpr (SourceLocation L, QualType FNTy, IdentKind IK,
1983- TypeSourceInfo *Info);
1984- PredefinedExpr (SourceLocation L, QualType FNTy, IdentKind IK,
1985- Expr *E);
19861976
19871977 explicit PredefinedExpr (EmptyShell Empty, bool HasFunctionName);
19881978
@@ -1995,39 +1985,10 @@ class PredefinedExpr final
19951985 *getTrailingObjects<Stmt *>() = SL;
19961986 }
19971987
1998- void setTypeSourceInfo (TypeSourceInfo *Info) {
1999- assert (!hasFunctionName () && getIdentKind () == UniqueStableNameType &&
2000- " TypeSourceInfo only valid for UniqueStableName of a Type" );
2001- *getTrailingObjects<TypeSourceInfo *>() = Info;
2002- }
2003-
2004- void setExpr (Expr *E) {
2005- assert (!hasFunctionName () && getIdentKind () == UniqueStableNameExpr &&
2006- " TypeSourceInfo only valid for UniqueStableName of n Expression." );
2007- *getTrailingObjects<Expr *>() = E;
2008- }
2009-
2010- size_t numTrailingObjects (OverloadToken<Stmt *>) const {
2011- return hasFunctionName ();
2012- }
2013-
2014- size_t numTrailingObjects (OverloadToken<TypeSourceInfo *>) const {
2015- return getIdentKind () == UniqueStableNameType && !hasFunctionName ();
2016- }
2017- size_t numTrailingObjects (OverloadToken<Expr *>) const {
2018- return getIdentKind () == UniqueStableNameExpr && !hasFunctionName ();
2019- }
2020-
20211988public:
20221989 // / Create a PredefinedExpr.
20231990 static PredefinedExpr *Create (const ASTContext &Ctx, SourceLocation L,
20241991 QualType FNTy, IdentKind IK, StringLiteral *SL);
2025- static PredefinedExpr *Create (const ASTContext &Ctx, SourceLocation L,
2026- QualType FNTy, IdentKind IK, StringLiteral *SL,
2027- TypeSourceInfo *Info);
2028- static PredefinedExpr *Create (const ASTContext &Ctx, SourceLocation L,
2029- QualType FNTy, IdentKind IK, StringLiteral *SL,
2030- Expr *E);
20311992
20321993 // / Create an empty PredefinedExpr.
20331994 static PredefinedExpr *CreateEmpty (const ASTContext &Ctx,
@@ -2052,38 +2013,12 @@ class PredefinedExpr final
20522013 : nullptr ;
20532014 }
20542015
2055- TypeSourceInfo *getTypeSourceInfo () {
2056- assert (!hasFunctionName () && getIdentKind () == UniqueStableNameType &&
2057- " TypeSourceInfo only valid for UniqueStableName of a Type" );
2058- return *getTrailingObjects<TypeSourceInfo *>();
2059- }
2060-
2061- const TypeSourceInfo *getTypeSourceInfo () const {
2062- assert (!hasFunctionName () && getIdentKind () == UniqueStableNameType &&
2063- " TypeSourceInfo only valid for UniqueStableName of a Type" );
2064- return *getTrailingObjects<TypeSourceInfo *>();
2065- }
2066-
2067- Expr *getExpr () {
2068- assert (!hasFunctionName () && getIdentKind () == UniqueStableNameExpr &&
2069- " TypeSourceInfo only valid for UniqueStableName of n Expression." );
2070- return *getTrailingObjects<Expr *>();
2071- }
2072-
2073- const Expr *getExpr () const {
2074- assert (!hasFunctionName () && getIdentKind () == UniqueStableNameExpr &&
2075- " TypeSourceInfo only valid for UniqueStableName of n Expression." );
2076- return *getTrailingObjects<Expr *>();
2077- }
2078-
20792016 static StringRef getIdentKindName (IdentKind IK);
20802017 StringRef getIdentKindName () const {
20812018 return getIdentKindName (getIdentKind ());
20822019 }
20832020
20842021 static std::string ComputeName (IdentKind IK, const Decl *CurrentDecl);
2085- static std::string ComputeName (ASTContext &Context, IdentKind IK,
2086- const QualType Ty);
20872022
20882023 SourceLocation getBeginLoc () const { return getLocation (); }
20892024 SourceLocation getEndLoc () const { return getLocation (); }
@@ -2104,6 +2039,64 @@ class PredefinedExpr final
21042039 }
21052040};
21062041
2042+ // This represents a use of the __builtin_sycl_unique_stable_name, which takes a
2043+ // type-id, and at CodeGen time emits a unique string representation of the
2044+ // type in a way that permits us to properly encode information about the SYCL
2045+ // kernels.
2046+ class SYCLUniqueStableNameExpr final : public Expr {
2047+ friend class ASTStmtReader ;
2048+ SourceLocation OpLoc, LParen, RParen;
2049+ TypeSourceInfo *TypeInfo;
2050+
2051+ SYCLUniqueStableNameExpr (EmptyShell Empty, QualType ResultTy);
2052+ SYCLUniqueStableNameExpr (SourceLocation OpLoc, SourceLocation LParen,
2053+ SourceLocation RParen, QualType ResultTy,
2054+ TypeSourceInfo *TSI);
2055+
2056+ void setTypeSourceInfo (TypeSourceInfo *Ty) { TypeInfo = Ty; }
2057+
2058+ void setLocation (SourceLocation L) { OpLoc = L; }
2059+ void setLParenLocation (SourceLocation L) { LParen = L; }
2060+ void setRParenLocation (SourceLocation L) { RParen = L; }
2061+
2062+ public:
2063+ TypeSourceInfo *getTypeSourceInfo () { return TypeInfo; }
2064+
2065+ const TypeSourceInfo *getTypeSourceInfo () const { return TypeInfo; }
2066+
2067+ static SYCLUniqueStableNameExpr *
2068+ Create (const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen,
2069+ SourceLocation RParen, TypeSourceInfo *TSI);
2070+
2071+ static SYCLUniqueStableNameExpr *CreateEmpty (const ASTContext &Ctx);
2072+
2073+ SourceLocation getBeginLoc () const { return getLocation (); }
2074+ SourceLocation getEndLoc () const { return RParen; }
2075+ SourceLocation getLocation () const { return OpLoc; }
2076+ SourceLocation getLParenLocation () const { return LParen; }
2077+ SourceLocation getRParenLocation () const { return RParen; }
2078+
2079+ static bool classof (const Stmt *T) {
2080+ return T->getStmtClass () == SYCLUniqueStableNameExprClass;
2081+ }
2082+
2083+ // Iterators
2084+ child_range children () {
2085+ return child_range (child_iterator (), child_iterator ());
2086+ }
2087+
2088+ const_child_range children () const {
2089+ return const_child_range (const_child_iterator (), const_child_iterator ());
2090+ }
2091+
2092+ // Convenience function to generate the name of the currently stored type.
2093+ std::string ComputeName (ASTContext &Context) const ;
2094+
2095+ // Get the generated name of the type. Note that this only works after all
2096+ // kernels have been instantiated.
2097+ static std::string ComputeName (ASTContext &Context, QualType Ty);
2098+ };
2099+
21072100// / ParenExpr - This represents a parethesized expression, e.g. "(1)". This
21082101// / AST node is only formed if full location information is requested.
21092102class ParenExpr : public Expr {
0 commit comments