Skip to content

Commit cec49a5

Browse files
committed
Revert "[SYCL] Implement __builtin_unique_stable_name."
This reverts commit b5a034e. This feature was added without following the proper process.
1 parent cddb49b commit cec49a5

File tree

14 files changed

+14
-495
lines changed

14 files changed

+14
-495
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,30 +2218,6 @@ argument.
22182218
int *pb =__builtin_preserve_access_index(&v->c[3].b);
22192219
__builtin_preserve_access_index(v->j);
22202220
2221-
``__builtin_unique_stable_name``
2222-
--------------------------------
2223-
2224-
``__builtin_unique_stable_name()`` is a builtin that takes a type or expression and
2225-
produces a string literal containing a unique name for the type (or type of the
2226-
expression) that is stable across split compilations.
2227-
2228-
In cases where the split compilation needs to share a unique token for a type
2229-
across the boundary (such as in an offloading situation), this name can be used
2230-
for lookup purposes.
2231-
2232-
This builtin is superior to RTTI for this purpose for two reasons. First, this
2233-
value is computed entirely at compile time, so it can be used in constant
2234-
expressions. Second, this value encodes lambda functions based on line-number
2235-
rather than the order in which it appears in a function. This is valuable
2236-
because it is stable in cases where an unrelated lambda is introduced
2237-
conditionally in the same function.
2238-
2239-
The current implementation of this builtin uses a slightly modified Itanium
2240-
Mangler to produce the unique name. The lambda ordinal is replaced with one or
2241-
more line/column pairs in the format ``LINE->COL``, separated with a ``~``
2242-
character. Typically, only one pair will be included, however in the case of
2243-
macro expansions the entire macro expansion stack is expressed.
2244-
22452221
Multiprecision Arithmetic Builtins
22462222
----------------------------------
22472223

clang/include/clang/AST/Expr.h

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,17 +1930,13 @@ class StringLiteral final
19301930
/// [C99 6.4.2.2] - A predefined identifier such as __func__.
19311931
class PredefinedExpr final
19321932
: public Expr,
1933-
private llvm::TrailingObjects<PredefinedExpr, Stmt *, Expr *,
1934-
TypeSourceInfo *> {
1933+
private llvm::TrailingObjects<PredefinedExpr, Stmt *> {
19351934
friend class ASTStmtReader;
19361935
friend TrailingObjects;
19371936

19381937
// PredefinedExpr is optionally followed by a single trailing
19391938
// "Stmt *" for the predefined identifier. It is present if and only if
19401939
// hasFunctionName() is true and is always a "StringLiteral *".
1941-
// It can also be followed by a Expr* in the case of a
1942-
// __builtin_unique_stable_name with an expression, or TypeSourceInfo * if
1943-
// __builtin_unique_stable_name with a type.
19441940

19451941
public:
19461942
enum IdentKind {
@@ -1953,18 +1949,12 @@ class PredefinedExpr final
19531949
PrettyFunction,
19541950
/// The same as PrettyFunction, except that the
19551951
/// 'virtual' keyword is omitted for virtual member functions.
1956-
PrettyFunctionNoVirtual,
1957-
UniqueStableNameType,
1958-
UniqueStableNameExpr,
1952+
PrettyFunctionNoVirtual
19591953
};
19601954

19611955
private:
19621956
PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
19631957
StringLiteral *SL);
1964-
PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
1965-
TypeSourceInfo *Info);
1966-
PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
1967-
Expr *E);
19681958

19691959
explicit PredefinedExpr(EmptyShell Empty, bool HasFunctionName);
19701960

@@ -1977,39 +1967,10 @@ class PredefinedExpr final
19771967
*getTrailingObjects<Stmt *>() = SL;
19781968
}
19791969

1980-
void setTypeSourceInfo(TypeSourceInfo *Info) {
1981-
assert(!hasFunctionName() && getIdentKind() == UniqueStableNameType &&
1982-
"TypeSourceInfo only valid for UniqueStableName of a Type");
1983-
*getTrailingObjects<TypeSourceInfo *>() = Info;
1984-
}
1985-
1986-
void setExpr(Expr *E) {
1987-
assert(!hasFunctionName() && getIdentKind() == UniqueStableNameExpr &&
1988-
"TypeSourceInfo only valid for UniqueStableName of n Expression.");
1989-
*getTrailingObjects<Expr *>() = E;
1990-
}
1991-
1992-
size_t numTrailingObjects(OverloadToken<Stmt *>) const {
1993-
return hasFunctionName();
1994-
}
1995-
1996-
size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
1997-
return getIdentKind() == UniqueStableNameType && !hasFunctionName();
1998-
}
1999-
size_t numTrailingObjects(OverloadToken<Expr *>) const {
2000-
return getIdentKind() == UniqueStableNameExpr && !hasFunctionName();
2001-
}
2002-
20031970
public:
20041971
/// Create a PredefinedExpr.
20051972
static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L,
20061973
QualType FNTy, IdentKind IK, StringLiteral *SL);
2007-
static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L,
2008-
QualType FNTy, IdentKind IK, StringLiteral *SL,
2009-
TypeSourceInfo *Info);
2010-
static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L,
2011-
QualType FNTy, IdentKind IK, StringLiteral *SL,
2012-
Expr *E);
20131974

20141975
/// Create an empty PredefinedExpr.
20151976
static PredefinedExpr *CreateEmpty(const ASTContext &Ctx,
@@ -2034,34 +1995,8 @@ class PredefinedExpr final
20341995
: nullptr;
20351996
}
20361997

2037-
TypeSourceInfo *getTypeSourceInfo() {
2038-
assert(!hasFunctionName() && getIdentKind() == UniqueStableNameType &&
2039-
"TypeSourceInfo only valid for UniqueStableName of a Type");
2040-
return *getTrailingObjects<TypeSourceInfo *>();
2041-
}
2042-
2043-
const TypeSourceInfo *getTypeSourceInfo() const {
2044-
assert(!hasFunctionName() && getIdentKind() == UniqueStableNameType &&
2045-
"TypeSourceInfo only valid for UniqueStableName of a Type");
2046-
return *getTrailingObjects<TypeSourceInfo *>();
2047-
}
2048-
2049-
Expr *getExpr() {
2050-
assert(!hasFunctionName() && getIdentKind() == UniqueStableNameExpr &&
2051-
"TypeSourceInfo only valid for UniqueStableName of n Expression.");
2052-
return *getTrailingObjects<Expr *>();
2053-
}
2054-
2055-
const Expr *getExpr() const {
2056-
assert(!hasFunctionName() && getIdentKind() == UniqueStableNameExpr &&
2057-
"TypeSourceInfo only valid for UniqueStableName of n Expression.");
2058-
return *getTrailingObjects<Expr *>();
2059-
}
2060-
20611998
static StringRef getIdentKindName(IdentKind IK);
20621999
static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl);
2063-
static std::string ComputeName(ASTContext &Context, IdentKind IK,
2064-
const QualType Ty);
20652000

20662001
SourceLocation getBeginLoc() const { return getLocation(); }
20672002
SourceLocation getEndLoc() const { return getLocation(); }

clang/include/clang/AST/Mangle.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,9 @@ class MangleContext {
152152
};
153153

154154
class ItaniumMangleContext : public MangleContext {
155-
bool IsUniqueNameMangler = false;
156155
public:
157156
explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D)
158157
: MangleContext(C, D, MK_Itanium) {}
159-
explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D,
160-
bool IsUniqueNameMangler)
161-
: MangleContext(C, D, MK_Itanium),
162-
IsUniqueNameMangler(IsUniqueNameMangler) {}
163158

164159
virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &) = 0;
165160
virtual void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &) = 0;
@@ -180,15 +175,12 @@ class ItaniumMangleContext : public MangleContext {
180175

181176
virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 0;
182177

183-
bool isUniqueNameMangler() { return IsUniqueNameMangler; }
184-
185178
static bool classof(const MangleContext *C) {
186179
return C->getKind() == MK_Itanium;
187180
}
188181

189182
static ItaniumMangleContext *create(ASTContext &Context,
190-
DiagnosticsEngine &Diags,
191-
bool IsUniqueNameMangler = false);
183+
DiagnosticsEngine &Diags);
192184
};
193185

194186
class MicrosoftMangleContext : public MangleContext {

clang/include/clang/Basic/TokenKinds.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ ALIAS("__char16_t" , char16_t , KEYCXX)
698698
ALIAS("__char32_t" , char32_t , KEYCXX)
699699
KEYWORD(__builtin_bit_cast , KEYALL)
700700
KEYWORD(__builtin_available , KEYALL)
701-
KEYWORD(__builtin_unique_stable_name, KEYALL)
702701

703702
// Clang-specific keywords enabled only in testing.
704703
TESTING_KEYWORD(__unknown_anytype , KEYALL)

clang/include/clang/Parse/Parser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,6 @@ class Parser : public CodeCompletionHandler {
18241824
ExprResult ParsePostfixExpressionSuffix(ExprResult LHS);
18251825
ExprResult ParseUnaryExprOrTypeTraitExpression();
18261826
ExprResult ParseBuiltinPrimaryExpression();
1827-
ExprResult ParseUniqueStableNameExpression();
18281827

18291828
ExprResult ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok,
18301829
bool &isCastExpr,

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,15 +4919,6 @@ class Sema final {
49194919
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
49204920
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
49214921

4922-
ExprResult BuildUniqueStableName(SourceLocation Loc, TypeSourceInfo *Operand);
4923-
ExprResult BuildUniqueStableName(SourceLocation Loc, Expr *E);
4924-
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc,
4925-
SourceLocation LParen,
4926-
SourceLocation RParen, ParsedType Ty);
4927-
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc,
4928-
SourceLocation LParen,
4929-
SourceLocation RParen, Expr *E);
4930-
49314922
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
49324923

49334924
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);

clang/lib/AST/Expr.cpp

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -510,34 +510,6 @@ PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
510510
setDependence(computeDependence(this));
511511
}
512512

513-
PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FnTy, IdentKind IK,
514-
TypeSourceInfo *Info)
515-
: Expr(PredefinedExprClass, FnTy, VK_LValue, OK_Ordinary) {
516-
PredefinedExprBits.Kind = IK;
517-
assert((getIdentKind() == IK) &&
518-
"IdentKind do not fit in PredefinedExprBitFields!");
519-
assert(IK == UniqueStableNameType &&
520-
"Constructor only valid with UniqueStableNameType");
521-
PredefinedExprBits.HasFunctionName = false;
522-
PredefinedExprBits.Loc = L;
523-
setTypeSourceInfo(Info);
524-
setDependence(computeDependence(this));
525-
}
526-
527-
PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FnTy, IdentKind IK,
528-
Expr *E)
529-
: Expr(PredefinedExprClass, FnTy, VK_LValue, OK_Ordinary) {
530-
PredefinedExprBits.Kind = IK;
531-
assert((getIdentKind() == IK) &&
532-
"IdentKind do not fit in PredefinedExprBitFields!");
533-
assert(IK == UniqueStableNameExpr &&
534-
"Constructor only valid with UniqueStableNameExpr");
535-
PredefinedExprBits.HasFunctionName = false;
536-
PredefinedExprBits.Loc = L;
537-
setExpr(E);
538-
setDependence(computeDependence(this));
539-
}
540-
541513
PredefinedExpr::PredefinedExpr(EmptyShell Empty, bool HasFunctionName)
542514
: Expr(PredefinedExprClass, Empty) {
543515
PredefinedExprBits.HasFunctionName = HasFunctionName;
@@ -547,44 +519,15 @@ PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
547519
QualType FNTy, IdentKind IK,
548520
StringLiteral *SL) {
549521
bool HasFunctionName = SL != nullptr;
550-
void *Mem = Ctx.Allocate(
551-
totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(HasFunctionName, 0, 0),
552-
alignof(PredefinedExpr));
553-
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
554-
}
555-
556-
PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
557-
QualType FNTy, IdentKind IK,
558-
StringLiteral *SL,
559-
TypeSourceInfo *Info) {
560-
assert(IK == UniqueStableNameType && "Only valid with UniqueStableNameType");
561-
bool HasFunctionName = SL != nullptr;
562-
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(
563-
HasFunctionName, 0, !HasFunctionName),
564-
alignof(PredefinedExpr));
565-
if (HasFunctionName)
566-
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
567-
return new (Mem) PredefinedExpr(L, FNTy, IK, Info);
568-
}
569-
570-
PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
571-
QualType FNTy, IdentKind IK,
572-
StringLiteral *SL, Expr *E) {
573-
assert(IK == UniqueStableNameExpr && "Only valid with UniqueStableNameExpr");
574-
bool HasFunctionName = SL != nullptr;
575-
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(
576-
HasFunctionName, !HasFunctionName, 0),
522+
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
577523
alignof(PredefinedExpr));
578-
if (HasFunctionName)
579-
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
580-
return new (Mem) PredefinedExpr(L, FNTy, IK, E);
524+
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
581525
}
582526

583527
PredefinedExpr *PredefinedExpr::CreateEmpty(const ASTContext &Ctx,
584528
bool HasFunctionName) {
585-
void *Mem = Ctx.Allocate(
586-
totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(HasFunctionName, 0, 0),
587-
alignof(PredefinedExpr));
529+
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
530+
alignof(PredefinedExpr));
588531
return new (Mem) PredefinedExpr(EmptyShell(), HasFunctionName);
589532
}
590533

@@ -604,28 +547,12 @@ StringRef PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
604547
return "__FUNCSIG__";
605548
case LFuncSig:
606549
return "L__FUNCSIG__";
607-
case UniqueStableNameType:
608-
case UniqueStableNameExpr:
609-
return "__builtin_unique_stable_name";
610550
case PrettyFunctionNoVirtual:
611551
break;
612552
}
613553
llvm_unreachable("Unknown ident kind for PredefinedExpr");
614554
}
615555

616-
std::string PredefinedExpr::ComputeName(ASTContext &Context, IdentKind IK,
617-
QualType Ty) {
618-
std::unique_ptr<MangleContext> Ctx{ItaniumMangleContext::create(
619-
Context, Context.getDiagnostics(), /*IsUniqueNameMangler*/ true)};
620-
621-
Ty = Ty.getCanonicalType();
622-
623-
SmallString<256> Buffer;
624-
llvm::raw_svector_ostream Out(Buffer);
625-
Ctx->mangleTypeName(Ty, Out);
626-
return std::string(Buffer.str());
627-
}
628-
629556
// FIXME: Maybe this should use DeclPrinter with a special "print predefined
630557
// expr" policy instead.
631558
std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {

0 commit comments

Comments
 (0)