Revert my user-defined literal commits - r1124{58,60,67} pending
some issues being sorted out.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112493 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 1529b0c..450348b 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -2422,50 +2422,6 @@
virtual child_iterator child_end();
};
-/// UDLiteralExpr - An expression for a user-defined
-/// string literal (e.g. "foo"_bar)
-///
-/// Both the DeclRefExpr and the IntegerConstant are fictional expressions
-/// generated from the literal.
-class UDLiteralExpr : public CallExpr {
- Expr *BaseLiteral;
-
- static bool isValidLiteral(Expr *E) {
- return isa<StringLiteral>(E) || isa<FloatingLiteral>(E) ||
- isa<IntegerLiteral>(E) || isa<CharacterLiteral>(E);
- }
-public:
- UDLiteralExpr(ASTContext &C, Expr *E, Expr *fn, Expr **args,
- unsigned numargs, QualType t)
- : CallExpr(C, UDLiteralExprClass, fn, args, numargs, t, SourceLocation())
- , BaseLiteral(E) {
- assert(isValidLiteral(E) && "Base literal must be an actual literal");
- }
-
- FunctionDecl *getLiteralOperator() { return getDirectCallee(); }
- const FunctionDecl *getLiteralOperator() const { return getDirectCallee(); }
-
- Expr *getBaseLiteral() { return BaseLiteral; }
- const Expr *getBaseLiteral() const { return BaseLiteral; }
- void setBaseLiteral(Expr *E) {
- assert(isValidLiteral(E) && "Base literal must be an actual literal");
- BaseLiteral = E;
- }
-
- IdentifierInfo *getUDSuffix() const {
- return getLiteralOperator()->getDeclName().getCXXLiteralIdentifier();
- }
-
- virtual SourceRange getSourceRange() const {
- return getBaseLiteral()->getSourceRange();
- }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == UDLiteralExprClass;
- }
- static bool classof(const UDLiteralExpr *) { return true; }
-};
-
inline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
if (isa<UnresolvedLookupExpr>(this))
return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index a360cbd..79ac072 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -1694,7 +1694,6 @@
DEF_TRAVERSE_STMT(CallExpr, { })
DEF_TRAVERSE_STMT(CXXMemberCallExpr, { })
DEF_TRAVERSE_STMT(CXXOperatorCallExpr, { })
-DEF_TRAVERSE_STMT(UDLiteralExpr, { })
// These operators (all of them) do not need any action except
// iterating over the children.
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td
index 1ae956e..dcb05c8 100644
--- a/include/clang/Basic/DiagnosticLexKinds.td
+++ b/include/clang/Basic/DiagnosticLexKinds.td
@@ -99,9 +99,6 @@
"maximum length %1 that %select{C90|ISO C99|C++}2 compilers are required to "
"support">, InGroup<OverlengthStrings>;
-def err_ud_suffix_mismatch : Error<"User-defined literal suffixes on adjacent "
- "string literal tokens do not match">;
-
//===----------------------------------------------------------------------===//
// PTH Diagnostics
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index e85ce4f..32550dc 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2946,15 +2946,9 @@
// C++ literal operators
def err_literal_operator_outside_namespace : Error<
"literal operator %0 must be in a namespace or global scope">;
-def warn_literal_operator_no_underscore : Warning< "literal operator names not "
- "beginning with underscores are reserved for future standardization">;
-def err_literal_operator_overload : Error<
- "no matching literal operator function for user-defined suffix '%0'">;
-def err_literal_operator_deleted : Error<
- "deleted literal operator function for user-defined suffix '%0'">;
-// FIXME: This should really provide information about what is allowed.
+// FIXME: This diagnostic sucks
def err_literal_operator_params : Error<
- "parameter declaration for literal operator '%0' is not valid">;
+ "parameter declaration for literal operator %0 is not valid">;
// C++ conversion functions
def err_conv_function_not_member : Error<
diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td
index 2b446c6..a2f6973 100644
--- a/include/clang/Basic/StmtNodes.td
+++ b/include/clang/Basic/StmtNodes.td
@@ -112,9 +112,6 @@
def UnresolvedLookupExpr : DStmt<OverloadExpr>;
def UnresolvedMemberExpr : DStmt<OverloadExpr>;
-// C++0x expressions
-def UDLiteralExpr : DStmt<Expr>;
-
// Obj-C Expressions.
def ObjCStringLiteral : DStmt<Expr>;
def ObjCEncodeExpr : DStmt<Expr>;
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index e05113d..9e0fb7e 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -17,7 +17,6 @@
#include "clang/Lex/PreprocessorLexer.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Allocator.h"
#include <string>
#include <vector>
#include <cassert>
@@ -68,9 +67,6 @@
// line" flag set on it.
bool IsAtStartOfLine;
- // ExtraDataAllocator - An allocator for extra data on a token.
- llvm::BumpPtrAllocator ExtraDataAllocator;
-
Lexer(const Lexer&); // DO NOT IMPLEMENT
void operator=(const Lexer&); // DO NOT IMPLEMENT
friend class Preprocessor;
diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h
index 40112f5..ba46fb1 100644
--- a/include/clang/Lex/LiteralSupport.h
+++ b/include/clang/Lex/LiteralSupport.h
@@ -27,7 +27,6 @@
class Token;
class SourceLocation;
class TargetInfo;
-class IdentifierInfo;
/// NumericLiteralParser - This performs strict semantic analysis of the content
/// of a ppnumber, classifying it as either integer, floating, or erroneous,
@@ -146,7 +145,6 @@
unsigned wchar_tByteWidth;
llvm::SmallString<512> ResultBuf;
char *ResultPtr; // cursor
- IdentifierInfo *UDSuffix;
public:
StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
Preprocessor &PP, bool Complain = true);
@@ -157,9 +155,6 @@
const char *GetString() { return &ResultBuf[0]; }
unsigned GetStringLength() const { return ResultPtr-&ResultBuf[0]; }
- bool isUserDefinedLiteral() const { return UDSuffix; }
- IdentifierInfo *getUDSuffix() const { return UDSuffix; }
-
unsigned GetNumStringChars() const {
if (AnyWide)
return GetStringLength() / wchar_tByteWidth;
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 94e858d..6b9b89e 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -645,7 +645,7 @@
/// copy). The caller is not allowed to modify the returned buffer pointer
/// if an internal buffer is returned.
unsigned getSpelling(const Token &Tok, const char *&Buffer,
- bool *Invalid = 0, bool LiteralOnly = false) const;
+ bool *Invalid = 0) const;
/// getSpelling - This method is used to get the spelling of a token into a
/// SmallVector. Note that the returned StringRef may not point to the
diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h
index b4639cf..bd9b468 100644
--- a/include/clang/Lex/Token.h
+++ b/include/clang/Lex/Token.h
@@ -14,16 +14,16 @@
#ifndef LLVM_CLANG_TOKEN_H
#define LLVM_CLANG_TOKEN_H
-#include "llvm/Support/Allocator.h"
#include "clang/Basic/TemplateKinds.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/OperatorKinds.h"
-#include "clang/Basic/IdentifierTable.h"
#include <cstdlib>
namespace clang {
+class IdentifierInfo;
+
/// Token - This structure provides full information about a lexed token.
/// It is not intended to be space efficient, it is intended to return as much
/// information as possible about each returned token. This is expected to be
@@ -34,14 +34,6 @@
/// can be represented by a single typename annotation token that carries
/// information about the SourceRange of the tokens and the type object.
class Token {
- /// An extra-large structure for storing the data needed for a user-defined
- /// literal - the raw literal, and the identifier suffix.
- struct UDLData {
- IdentifierInfo *II;
- const char *LiteralData;
- unsigned LiteralLength;
- };
-
/// The location of the token.
SourceLocation Loc;
@@ -55,7 +47,7 @@
/// token.
unsigned UintData;
- /// PtrData - This is a union of five different pointer types, which depends
+ /// PtrData - This is a union of four different pointer types, which depends
/// on what type of token this is:
/// Identifiers, keywords, etc:
/// This is an IdentifierInfo*, which contains the uniqued identifier
@@ -63,8 +55,6 @@
/// Literals: isLiteral() returns true.
/// This is a pointer to the start of the token in a text buffer, which
/// may be dirty (have trigraphs / escaped newlines).
- /// User-defined literals: isUserDefinedLiteral() returns true.
- /// This is a pointer to a UDLData.
/// Annotations (resolved type names, C++ scopes, etc): isAnnotation().
/// This is a pointer to sema-specific data for the annotation token.
/// Other:
@@ -81,14 +71,12 @@
unsigned char Flags;
public:
- /// Various flags set per token:
+ // Various flags set per token:
enum TokenFlags {
- StartOfLine = 0x01, ///< At start of line or only after whitespace
- LeadingSpace = 0x02, ///< Whitespace exists before this token
- DisableExpand = 0x04, ///< This identifier may never be macro expanded
- NeedsCleaning = 0x08, ///< Contained an escaped newline or trigraph
- UserDefinedLiteral = 0x10, ///< This literal has a ud-suffix
- LiteralPortionClean = 0x20 ///< A UDL's literal portion needs no cleaning
+ StartOfLine = 0x01, // At start of line or only after whitespace.
+ LeadingSpace = 0x02, // Whitespace exists before this token.
+ DisableExpand = 0x04, // This identifier may never be macro expanded.
+ NeedsCleaning = 0x08 // Contained an escaped newline or trigraph.
};
tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }
@@ -120,34 +108,12 @@
assert(!isAnnotation() && "Annotation tokens have no length field");
return UintData;
}
- /// getLiteralLength - Return the length of the literal portion of the token,
- /// which may not be the token length if this is a user-defined literal.
- unsigned getLiteralLength() const {
- assert(isLiteral() && "Using getLiteralLength on a non-literal token");
- if (isUserDefinedLiteral())
- return reinterpret_cast<UDLData*>(PtrData)->LiteralLength;
- else
- return UintData;
- }
void setLocation(SourceLocation L) { Loc = L; }
void setLength(unsigned Len) {
assert(!isAnnotation() && "Annotation tokens have no length field");
UintData = Len;
}
- void setLiteralLength(unsigned Len) {
- assert(isLiteral() && "Using setLiteralLength on a non-literal token");
- if (isUserDefinedLiteral())
- reinterpret_cast<UDLData*>(PtrData)->LiteralLength = Len;
- else
- UintData = Len;
- }
-
- /// makeUserDefinedLiteral - Set this token to be a user-defined literal
- void makeUserDefinedLiteral(llvm::BumpPtrAllocator &Alloc) {
- PtrData = new (Alloc.Allocate(sizeof(UDLData), 4)) UDLData();
- setFlag(UserDefinedLiteral);
- }
SourceLocation getAnnotationEndLoc() const {
assert(isAnnotation() && "Used AnnotEndLocID on non-annotation token");
@@ -188,18 +154,11 @@
IdentifierInfo *getIdentifierInfo() const {
assert(!isAnnotation() && "Used IdentInfo on annotation token!");
- if (isUserDefinedLiteral())
- return reinterpret_cast<UDLData*>(PtrData)->II;
- else if (isLiteral())
- return 0;
- else
- return reinterpret_cast<IdentifierInfo*>(PtrData);
+ if (isLiteral()) return 0;
+ return (IdentifierInfo*) PtrData;
}
void setIdentifierInfo(IdentifierInfo *II) {
- if (isUserDefinedLiteral())
- reinterpret_cast<UDLData*>(PtrData)->II = II;
- else
- PtrData = (void*)II;
+ PtrData = (void*) II;
}
/// getLiteralData - For a literal token (numeric constant, string, etc), this
@@ -207,17 +166,11 @@
/// otherwise.
const char *getLiteralData() const {
assert(isLiteral() && "Cannot get literal data of non-literal");
- if (isUserDefinedLiteral())
- return reinterpret_cast<UDLData*>(PtrData)->LiteralData;
- else
- return reinterpret_cast<const char*>(PtrData);
+ return reinterpret_cast<const char*>(PtrData);
}
void setLiteralData(const char *Ptr) {
assert(isLiteral() && "Cannot set literal data of non-literal");
- if (isUserDefinedLiteral())
- reinterpret_cast<UDLData*>(PtrData)->LiteralData = Ptr;
- else
- PtrData = const_cast<char*>(Ptr);
+ PtrData = const_cast<char*>(Ptr);
}
void *getAnnotationValue() const {
@@ -268,12 +221,6 @@
return (Flags & DisableExpand) ? true : false;
}
- /// isUserDefinedLiteral - Return true if this is a C++0x user-defined literal
- /// token.
- bool isUserDefinedLiteral() const {
- return (Flags & UserDefinedLiteral) ? true : false;
- }
-
/// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const;
@@ -282,17 +229,8 @@
/// needsCleaning - Return true if this token has trigraphs or escaped
/// newlines in it.
- bool needsCleaning() const {
- return (Flags & NeedsCleaning) ? true : false;
- }
-
- /// literalNeedsCleaning - Return true if the literal portion of this token
- /// needs cleaning.
- bool literalNeedsCleaning() const {
- assert(isLiteral() && "Using literalNeedsCleaning on a non-literal token");
- return (Flags & NeedsCleaning) ? ((Flags & LiteralPortionClean) ? false : true)
- : false;
- }
+ ///
+ bool needsCleaning() const { return (Flags & NeedsCleaning) ? true : false; }
};
/// PPConditionalInfo - Information about the conditional stack (#if directives)
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index d8c8b02..5558eae 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -1752,8 +1752,8 @@
/// ActOnStringLiteral - The specified tokens were lexed as pasted string
/// fragments (e.g. "foo" "bar" L"baz").
- virtual ExprResult ActOnStringLiteral(Scope *S, const Token *Toks,
- unsigned NumToks);
+ virtual ExprResult ActOnStringLiteral(const Token *Toks,
+ unsigned NumToks);
// Binary/Unary Operators. 'Tok' is the token for the operator.
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc,
@@ -2747,9 +2747,6 @@
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
- ExprResult BuildUDStringLiteralExpr(Scope *S, StringLiteral *SL, unsigned L,
- IdentifierInfo *II);
-
//===--------------------------------------------------------------------===//
// C++ Templates [C++ 14]
//