@@ -1948,17 +1948,13 @@ class StringLiteral final
1948
1948
// / [C99 6.4.2.2] - A predefined identifier such as __func__.
1949
1949
class PredefinedExpr final
1950
1950
: public Expr,
1951
- private llvm::TrailingObjects<PredefinedExpr, Stmt *, Expr *,
1952
- TypeSourceInfo *> {
1951
+ private llvm::TrailingObjects<PredefinedExpr, Stmt *> {
1953
1952
friend class ASTStmtReader ;
1954
1953
friend TrailingObjects;
1955
1954
1956
1955
// PredefinedExpr is optionally followed by a single trailing
1957
1956
// "Stmt *" for the predefined identifier. It is present if and only if
1958
1957
// 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.
1962
1958
1963
1959
public:
1964
1960
enum IdentKind {
@@ -1971,18 +1967,12 @@ class PredefinedExpr final
1971
1967
PrettyFunction,
1972
1968
// / The same as PrettyFunction, except that the
1973
1969
// / 'virtual' keyword is omitted for virtual member functions.
1974
- PrettyFunctionNoVirtual,
1975
- UniqueStableNameType,
1976
- UniqueStableNameExpr,
1970
+ PrettyFunctionNoVirtual
1977
1971
};
1978
1972
1979
1973
private:
1980
1974
PredefinedExpr (SourceLocation L, QualType FNTy, IdentKind IK,
1981
1975
StringLiteral *SL);
1982
- PredefinedExpr (SourceLocation L, QualType FNTy, IdentKind IK,
1983
- TypeSourceInfo *Info);
1984
- PredefinedExpr (SourceLocation L, QualType FNTy, IdentKind IK,
1985
- Expr *E);
1986
1976
1987
1977
explicit PredefinedExpr (EmptyShell Empty, bool HasFunctionName);
1988
1978
@@ -1995,39 +1985,10 @@ class PredefinedExpr final
1995
1985
*getTrailingObjects<Stmt *>() = SL;
1996
1986
}
1997
1987
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
-
2021
1988
public:
2022
1989
// / Create a PredefinedExpr.
2023
1990
static PredefinedExpr *Create (const ASTContext &Ctx, SourceLocation L,
2024
1991
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);
2031
1992
2032
1993
// / Create an empty PredefinedExpr.
2033
1994
static PredefinedExpr *CreateEmpty (const ASTContext &Ctx,
@@ -2052,38 +2013,12 @@ class PredefinedExpr final
2052
2013
: nullptr ;
2053
2014
}
2054
2015
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
-
2079
2016
static StringRef getIdentKindName (IdentKind IK);
2080
2017
StringRef getIdentKindName () const {
2081
2018
return getIdentKindName (getIdentKind ());
2082
2019
}
2083
2020
2084
2021
static std::string ComputeName (IdentKind IK, const Decl *CurrentDecl);
2085
- static std::string ComputeName (ASTContext &Context, IdentKind IK,
2086
- const QualType Ty);
2087
2022
2088
2023
SourceLocation getBeginLoc () const { return getLocation (); }
2089
2024
SourceLocation getEndLoc () const { return getLocation (); }
@@ -2104,6 +2039,64 @@ class PredefinedExpr final
2104
2039
}
2105
2040
};
2106
2041
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
+
2107
2100
// / ParenExpr - This represents a parethesized expression, e.g. "(1)". This
2108
2101
// / AST node is only formed if full location information is requested.
2109
2102
class ParenExpr : public Expr {
0 commit comments