Skip to content

Commit bd97889

Browse files
author
Erich Keane
committed
Revert old implementation sans tests
1 parent 9b61592 commit bd97889

16 files changed

+29
-541
lines changed

clang/docs/LanguageExtensions.rst

+2-26
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ correctly in any circumstances. It can be used if:
17941794
metaprogramming algorithms to be able to specify/detect types generically.
17951795
17961796
- the generated kernel binary does not contain indirect calls because they
1797-
are eliminated using compiler optimizations e.g. devirtualization.
1797+
are eliminated using compiler optimizations e.g. devirtualization.
17981798
17991799
- the selected target supports the function pointer like functionality e.g.
18001800
most CPU targets.
@@ -2404,30 +2404,6 @@ argument.
24042404
int *pb =__builtin_preserve_access_index(&v->c[3].b);
24052405
__builtin_preserve_access_index(v->j);
24062406
2407-
``__builtin_unique_stable_name``
2408-
--------------------------------
2409-
2410-
``__builtin_unique_stable_name()`` is a builtin that takes a type or expression and
2411-
produces a string literal containing a unique name for the type (or type of the
2412-
expression) that is stable across split compilations.
2413-
2414-
In cases where the split compilation needs to share a unique token for a type
2415-
across the boundary (such as in an offloading situation), this name can be used
2416-
for lookup purposes.
2417-
2418-
This builtin is superior to RTTI for this purpose for two reasons. First, this
2419-
value is computed entirely at compile time, so it can be used in constant
2420-
expressions. Second, this value encodes lambda functions based on line-number
2421-
rather than the order in which it appears in a function. This is valuable
2422-
because it is stable in cases where an unrelated lambda is introduced
2423-
conditionally in the same function.
2424-
2425-
The current implementation of this builtin uses a slightly modified Itanium
2426-
Mangler to produce the unique name. The lambda ordinal is replaced with one or
2427-
more line/column pairs in the format ``LINE->COL``, separated with a ``~``
2428-
character. Typically, only one pair will be included, however in the case of
2429-
macro expansions the entire macro expansion stack is expressed.
2430-
24312407
Multiprecision Arithmetic Builtins
24322408
----------------------------------
24332409
@@ -2622,7 +2598,7 @@ Guaranteed inlined copy
26222598
``__builtin_memcpy_inline`` has been designed as a building block for efficient
26232599
``memcpy`` implementations. It is identical to ``__builtin_memcpy`` but also
26242600
guarantees not to call any external functions. See LLVM IR `llvm.memcpy.inline
2625-
<https://llvm.org/docs/LangRef.html#llvm-memcpy-inline-intrinsic>`_ intrinsic
2601+
<https://llvm.org/docs/LangRef.html#llvm-memcpy-inline-intrinsic>`_ intrinsic
26262602
for more information.
26272603
26282604
This is useful to implement a custom version of ``memcpy``, implement a

clang/include/clang/AST/Expr.h

+2-67
Original file line numberDiff line numberDiff line change
@@ -1948,17 +1948,13 @@ class StringLiteral final
19481948
/// [C99 6.4.2.2] - A predefined identifier such as __func__.
19491949
class 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

19631959
public:
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

19791973
private:
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-
20211988
public:
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(); }

clang/include/clang/AST/Mangle.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,9 @@ class MangleContext {
172172
};
173173

174174
class ItaniumMangleContext : public MangleContext {
175-
bool IsUniqueNameMangler = false;
176175
public:
177176
explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D)
178177
: MangleContext(C, D, MK_Itanium) {}
179-
explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D,
180-
bool IsUniqueNameMangler)
181-
: MangleContext(C, D, MK_Itanium),
182-
IsUniqueNameMangler(IsUniqueNameMangler) {}
183178

184179
virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &) = 0;
185180
virtual void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &) = 0;
@@ -200,15 +195,12 @@ class ItaniumMangleContext : public MangleContext {
200195

201196
virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 0;
202197

203-
bool isUniqueNameMangler() { return IsUniqueNameMangler; }
204-
205198
static bool classof(const MangleContext *C) {
206199
return C->getKind() == MK_Itanium;
207200
}
208201

209202
static ItaniumMangleContext *create(ASTContext &Context,
210-
DiagnosticsEngine &Diags,
211-
bool IsUniqueNameMangler = false);
203+
DiagnosticsEngine &Diags);
212204
};
213205

214206
class MicrosoftMangleContext : public MangleContext {

clang/include/clang/Basic/TokenKinds.def

+5-6
Original file line numberDiff line numberDiff line change
@@ -695,12 +695,11 @@ ALIAS("_declspec" , __declspec , KEYMS)
695695
ALIAS("_pascal" , __pascal , KEYBORLAND)
696696

697697
// Clang Extensions.
698-
KEYWORD(__builtin_convertvector , KEYALL)
699-
ALIAS("__char16_t" , char16_t , KEYCXX)
700-
ALIAS("__char32_t" , char32_t , KEYCXX)
701-
KEYWORD(__builtin_bit_cast , KEYALL)
702-
KEYWORD(__builtin_available , KEYALL)
703-
KEYWORD(__builtin_unique_stable_name, KEYALL)
698+
KEYWORD(__builtin_convertvector , KEYALL)
699+
ALIAS("__char16_t" , char16_t , KEYCXX)
700+
ALIAS("__char32_t" , char32_t , KEYCXX)
701+
KEYWORD(__builtin_bit_cast , KEYALL)
702+
KEYWORD(__builtin_available , KEYALL)
704703

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

clang/include/clang/Parse/Parser.h

-1
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,6 @@ class Parser : public CodeCompletionHandler {
18001800
ExprResult ParsePostfixExpressionSuffix(ExprResult LHS);
18011801
ExprResult ParseUnaryExprOrTypeTraitExpression();
18021802
ExprResult ParseBuiltinPrimaryExpression();
1803-
ExprResult ParseUniqueStableNameExpression();
18041803

18051804
ExprResult ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok,
18061805
bool &isCastExpr,

clang/include/clang/Sema/Sema.h

-9
Original file line numberDiff line numberDiff line change
@@ -5420,15 +5420,6 @@ class Sema final {
54205420
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
54215421
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
54225422

5423-
ExprResult BuildUniqueStableName(SourceLocation Loc, TypeSourceInfo *Operand);
5424-
ExprResult BuildUniqueStableName(SourceLocation Loc, Expr *E);
5425-
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc,
5426-
SourceLocation LParen,
5427-
SourceLocation RParen, ParsedType Ty);
5428-
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc,
5429-
SourceLocation LParen,
5430-
SourceLocation RParen, Expr *E);
5431-
54325423
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
54335424

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

clang/lib/AST/Expr.cpp

+4-77
Original file line numberDiff line numberDiff line change
@@ -518,34 +518,6 @@ PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
518518
setDependence(computeDependence(this));
519519
}
520520

521-
PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FnTy, IdentKind IK,
522-
TypeSourceInfo *Info)
523-
: Expr(PredefinedExprClass, FnTy, VK_LValue, OK_Ordinary) {
524-
PredefinedExprBits.Kind = IK;
525-
assert((getIdentKind() == IK) &&
526-
"IdentKind do not fit in PredefinedExprBitFields!");
527-
assert(IK == UniqueStableNameType &&
528-
"Constructor only valid with UniqueStableNameType");
529-
PredefinedExprBits.HasFunctionName = false;
530-
PredefinedExprBits.Loc = L;
531-
setTypeSourceInfo(Info);
532-
setDependence(computeDependence(this));
533-
}
534-
535-
PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FnTy, IdentKind IK,
536-
Expr *E)
537-
: Expr(PredefinedExprClass, FnTy, VK_LValue, OK_Ordinary) {
538-
PredefinedExprBits.Kind = IK;
539-
assert((getIdentKind() == IK) &&
540-
"IdentKind do not fit in PredefinedExprBitFields!");
541-
assert(IK == UniqueStableNameExpr &&
542-
"Constructor only valid with UniqueStableNameExpr");
543-
PredefinedExprBits.HasFunctionName = false;
544-
PredefinedExprBits.Loc = L;
545-
setExpr(E);
546-
setDependence(computeDependence(this));
547-
}
548-
549521
PredefinedExpr::PredefinedExpr(EmptyShell Empty, bool HasFunctionName)
550522
: Expr(PredefinedExprClass, Empty) {
551523
PredefinedExprBits.HasFunctionName = HasFunctionName;
@@ -555,44 +527,15 @@ PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
555527
QualType FNTy, IdentKind IK,
556528
StringLiteral *SL) {
557529
bool HasFunctionName = SL != nullptr;
558-
void *Mem = Ctx.Allocate(
559-
totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(HasFunctionName, 0, 0),
560-
alignof(PredefinedExpr));
561-
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
562-
}
563-
564-
PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
565-
QualType FNTy, IdentKind IK,
566-
StringLiteral *SL,
567-
TypeSourceInfo *Info) {
568-
assert(IK == UniqueStableNameType && "Only valid with UniqueStableNameType");
569-
bool HasFunctionName = SL != nullptr;
570-
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(
571-
HasFunctionName, 0, !HasFunctionName),
572-
alignof(PredefinedExpr));
573-
if (HasFunctionName)
574-
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
575-
return new (Mem) PredefinedExpr(L, FNTy, IK, Info);
576-
}
577-
578-
PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
579-
QualType FNTy, IdentKind IK,
580-
StringLiteral *SL, Expr *E) {
581-
assert(IK == UniqueStableNameExpr && "Only valid with UniqueStableNameExpr");
582-
bool HasFunctionName = SL != nullptr;
583-
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(
584-
HasFunctionName, !HasFunctionName, 0),
530+
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
585531
alignof(PredefinedExpr));
586-
if (HasFunctionName)
587-
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
588-
return new (Mem) PredefinedExpr(L, FNTy, IK, E);
532+
return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
589533
}
590534

591535
PredefinedExpr *PredefinedExpr::CreateEmpty(const ASTContext &Ctx,
592536
bool HasFunctionName) {
593-
void *Mem = Ctx.Allocate(
594-
totalSizeToAlloc<Stmt *, Expr *, TypeSourceInfo *>(HasFunctionName, 0, 0),
595-
alignof(PredefinedExpr));
537+
void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
538+
alignof(PredefinedExpr));
596539
return new (Mem) PredefinedExpr(EmptyShell(), HasFunctionName);
597540
}
598541

@@ -612,28 +555,12 @@ StringRef PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
612555
return "__FUNCSIG__";
613556
case LFuncSig:
614557
return "L__FUNCSIG__";
615-
case UniqueStableNameType:
616-
case UniqueStableNameExpr:
617-
return "__builtin_unique_stable_name";
618558
case PrettyFunctionNoVirtual:
619559
break;
620560
}
621561
llvm_unreachable("Unknown ident kind for PredefinedExpr");
622562
}
623563

624-
std::string PredefinedExpr::ComputeName(ASTContext &Context, IdentKind IK,
625-
QualType Ty) {
626-
std::unique_ptr<MangleContext> Ctx{ItaniumMangleContext::create(
627-
Context, Context.getDiagnostics(), /*IsUniqueNameMangler*/ true)};
628-
629-
Ty = Ty.getCanonicalType();
630-
631-
SmallString<256> Buffer;
632-
llvm::raw_svector_ostream Out(Buffer);
633-
Ctx->mangleTypeName(Ty, Out);
634-
return std::string(Buffer.str());
635-
}
636-
637564
// FIXME: Maybe this should use DeclPrinter with a special "print predefined
638565
// expr" policy instead.
639566
std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {

0 commit comments

Comments
 (0)