[cfe-commits] r112493 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Lex/ include/clang/Sema/ lib/AST/ lib/Checker/ lib/CodeGen/ lib/Lex/ lib/Parse/ lib/Sema/ test/Parser/ test/SemaCXX/ tools/libclang/
Sean Hunt
scshunt at csclub.uwaterloo.ca
Mon Aug 30 10:47:05 PDT 2010
Author: coppro
Date: Mon Aug 30 12:47:05 2010
New Revision: 112493
URL: http://llvm.org/viewvc/llvm-project?rev=112493&view=rev
Log:
Revert my user-defined literal commits - r1124{58,60,67} pending
some issues being sorted out.
Removed:
cfe/trunk/test/SemaCXX/literal-operator-dcls.cpp
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/Token.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/Parser/cxx0x-literal-operators.cpp
cfe/trunk/test/SemaCXX/literal-operators.cpp
cfe/trunk/tools/libclang/CXCursor.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Aug 30 12:47:05 2010
@@ -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();
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Aug 30 12:47:05 2010
@@ -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.
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Mon Aug 30 12:47:05 2010
@@ -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
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Aug 30 12:47:05 2010
@@ -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<
Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/StmtNodes.td (original)
+++ cfe/trunk/include/clang/Basic/StmtNodes.td Mon Aug 30 12:47:05 2010
@@ -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>;
Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Mon Aug 30 12:47:05 2010
@@ -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;
Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Mon Aug 30 12:47:05 2010
@@ -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;
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Aug 30 12:47:05 2010
@@ -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
Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Mon Aug 30 12:47:05 2010
@@ -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)
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Aug 30 12:47:05 2010
@@ -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]
//
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Aug 30 12:47:05 2010
@@ -2423,8 +2423,7 @@
case Expr::UnaryTypeTraitExprClass:
return NoDiag();
case Expr::CallExprClass:
- case Expr::CXXOperatorCallExprClass:
- case Expr::UDLiteralExprClass: {
+ case Expr::CXXOperatorCallExprClass: {
const CallExpr *CE = cast<CallExpr>(E);
if (CE->isBuiltinCall(Ctx))
return CheckEvalInICE(E, Ctx);
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Aug 30 12:47:05 2010
@@ -1199,11 +1199,6 @@
}
}
-void StmtPrinter::VisitUDLiteralExpr(UDLiteralExpr *Node) {
- VisitStmt(Node->getBaseLiteral());
- OS << Node->getUDSuffix()->getName();
-}
-
static const char *getTypeTraitName(UnaryTypeTrait UTT) {
switch (UTT) {
default: assert(false && "Unknown type trait");
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Aug 30 12:47:05 2010
@@ -828,12 +828,6 @@
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
}
-void StmtProfiler::VisitUDLiteralExpr(UDLiteralExpr *S) {
- VisitExpr(S);
- VisitStmt(S->getBaseLiteral());
- ID.AddString(S->getUDSuffix()->getName());
-}
-
void StmtProfiler::VisitObjCStringLiteral(ObjCStringLiteral *S) {
VisitExpr(S);
}
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Mon Aug 30 12:47:05 2010
@@ -886,7 +886,6 @@
}
case Stmt::CallExprClass:
- case Stmt::UDLiteralExprClass:
case Stmt::CXXOperatorCallExprClass: {
const CallExpr* C = cast<CallExpr>(S);
VisitCall(C, Pred, C->arg_begin(), C->arg_end(), Dst, false);
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Aug 30 12:47:05 2010
@@ -210,9 +210,6 @@
return CGF.EmitCallExpr(E).getScalarVal();
}
- Value *VisitUDLiteralExpr(const UDLiteralExpr *E) {
- return VisitCallExpr(E);
- }
Value *VisitStmtExpr(const StmtExpr *E);
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Mon Aug 30 12:47:05 2010
@@ -1634,7 +1634,6 @@
break;
case Expr::CXXMemberCallExprClass: // fallthrough
- case Expr::UDLiteralExprClass:
case Expr::CallExprClass: {
const CallExpr *CE = cast<CallExpr>(E);
Out << "cl";
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Mon Aug 30 12:47:05 2010
@@ -548,11 +548,6 @@
isInited = true;
}
-/// isIdentifierStart - Return true if this is the start character of an
-/// identifier, which is [a-zA-Z_].
-static inline bool isIdentifierStart(unsigned char c) {
- return (CharInfo[c] & (CHAR_LETTER|CHAR_UNDER)) ? true : false;
-}
/// isIdentifierBody - Return true if this is the body character of an
/// identifier, which is [a-zA-Z0-9_].
@@ -1000,30 +995,8 @@
// Update the location of the token as well as the BufferPtr instance var.
const char *TokStart = BufferPtr;
- tok::TokenKind Kind = Wide ? tok::wide_string_literal : tok::string_literal;
-
- // FIXME: Handle UCNs
- unsigned Size;
- if (Features.CPlusPlus0x && PP &&
- isIdentifierStart(getCharAndSize(CurPtr, Size))) {
- Result.makeUserDefinedLiteral(ExtraDataAllocator);
- Result.setFlagValue(Token::LiteralPortionClean, !Result.needsCleaning());
- Result.setKind(Kind);
- Result.setLiteralLength(CurPtr - BufferPtr);
-
- // FIXME: We hack around the lexer's routines a lot here.
- BufferPtr = CurPtr;
- bool OldRawMode = LexingRawMode;
- LexingRawMode = true;
- LexIdentifier(Result, ConsumeChar(CurPtr, Size, Result));
- LexingRawMode = OldRawMode;
- PP->LookUpIdentifierInfo(Result, CurPtr);
-
- CurPtr = BufferPtr;
- BufferPtr = TokStart;
- }
-
- FormTokenWithChars(Result, CurPtr, Kind);
+ FormTokenWithChars(Result, CurPtr,
+ Wide ? tok::wide_string_literal : tok::string_literal);
Result.setLiteralData(TokStart);
}
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Mon Aug 30 12:47:05 2010
@@ -758,38 +758,30 @@
///
StringLiteralParser::
StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
- Preprocessor &pp, bool Complain) : PP(pp), hadError(false) {
+ Preprocessor &pp, bool Complain) : PP(pp) {
// Scan all of the string portions, remember the max individual token length,
// computing a bound on the concatenated string length, and see whether any
// piece is a wide-string. If any of the string portions is a wide-string
// literal, the result is a wide-string literal [C99 6.4.5p4].
- MaxTokenLength = StringToks[0].getLiteralLength();
- SizeBound = StringToks[0].getLiteralLength()-2; // -2 for "".
+ MaxTokenLength = StringToks[0].getLength();
+ SizeBound = StringToks[0].getLength()-2; // -2 for "".
AnyWide = StringToks[0].is(tok::wide_string_literal);
- UDSuffix = StringToks[0].getIdentifierInfo();
+
+ hadError = false;
// Implement Translation Phase #6: concatenation of string literals
/// (C99 5.1.1.2p1). The common case is only one string fragment.
for (unsigned i = 1; i != NumStringToks; ++i) {
// The string could be shorter than this if it needs cleaning, but this is a
// reasonable bound, which is all we need.
- SizeBound += StringToks[i].getLiteralLength()-2; // -2 for "".
+ SizeBound += StringToks[i].getLength()-2; // -2 for "".
// Remember maximum string piece length.
- if (StringToks[i].getLiteralLength() > MaxTokenLength)
- MaxTokenLength = StringToks[i].getLiteralLength();
+ if (StringToks[i].getLength() > MaxTokenLength)
+ MaxTokenLength = StringToks[i].getLength();
// Remember if we see any wide strings.
AnyWide |= StringToks[i].is(tok::wide_string_literal);
-
- if (StringToks[i].isUserDefinedLiteral()) {
- if (UDSuffix && UDSuffix != StringToks[i].getIdentifierInfo()) {
- // FIXME: Improve location and note previous
- PP.Diag(StringToks[0].getLocation(), diag::err_ud_suffix_mismatch);
- hadError = true;
- } else if (!UDSuffix)
- UDSuffix = StringToks[0].getIdentifierInfo();
- }
}
// Include space for the null terminator.
@@ -831,7 +823,7 @@
// and 'spelled' tokens can only shrink.
bool StringInvalid = false;
unsigned ThisTokLen = PP.getSpelling(StringToks[i], ThisTokBuf,
- &StringInvalid, true);
+ &StringInvalid);
if (StringInvalid) {
hadError = 1;
continue;
@@ -946,7 +938,7 @@
bool Complain) {
// Get the spelling of the token.
llvm::SmallString<16> SpellingBuffer;
- SpellingBuffer.resize(Tok.getLiteralLength());
+ SpellingBuffer.resize(Tok.getLength());
bool StringInvalid = false;
const char *SpellingPtr = &SpellingBuffer[0];
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Aug 30 12:47:05 2010
@@ -352,25 +352,15 @@
/// to point to a constant buffer with the data already in it (avoiding a
/// copy). The caller is not allowed to modify the returned buffer pointer
/// if an internal buffer is returned.
-///
-/// If LiteralOnly is specified, only the literal portion of the token is
-/// processed.
-unsigned Preprocessor::getSpelling(const Token &Tok, const char *&Buffer,
- bool *Invalid, bool LiteralOnly) const {
+unsigned Preprocessor::getSpelling(const Token &Tok,
+ const char *&Buffer, bool *Invalid) const {
assert((int)Tok.getLength() >= 0 && "Token character range is bogus!");
- assert((!LiteralOnly || Tok.isLiteral()) &&
- "LiteralOnly used on a non-literal token");
-
- unsigned (Token::*getLength) () const =
- LiteralOnly ? &Token::getLiteralLength : &Token::getLength;
// If this token is an identifier, just return the string from the identifier
// table, which is very quick.
if (const IdentifierInfo *II = Tok.getIdentifierInfo()) {
- if (!Tok.isUserDefinedLiteral()) {
- Buffer = II->getNameStart();
- return II->getLength();
- }
+ Buffer = II->getNameStart();
+ return II->getLength();
}
// Otherwise, compute the start of the token in the input lexer buffer.
@@ -391,20 +381,20 @@
}
// If this token contains nothing interesting, return it directly.
- if (!(LiteralOnly ? Tok.literalNeedsCleaning() : Tok.needsCleaning())) {
+ if (!Tok.needsCleaning()) {
Buffer = TokStart;
- return (Tok.*getLength)();
+ return Tok.getLength();
}
// Otherwise, hard case, relex the characters into the string.
char *OutBuf = const_cast<char*>(Buffer);
- for (const char *Ptr = TokStart, *End = TokStart+(Tok.*getLength)();
+ for (const char *Ptr = TokStart, *End = TokStart+Tok.getLength();
Ptr != End; ) {
unsigned CharSize;
*OutBuf++ = Lexer::getCharAndSizeNoWarn(Ptr, CharSize, Features);
Ptr += CharSize;
}
- assert(unsigned(OutBuf-Buffer) != (Tok.*getLength)() &&
+ assert(unsigned(OutBuf-Buffer) != Tok.getLength() &&
"NeedsCleaning flag set on something that didn't need cleaning!");
return OutBuf-Buffer;
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Aug 30 12:47:05 2010
@@ -1568,8 +1568,7 @@
} while (isTokenStringLiteral());
// Pass the set of string tokens, ready for concatenation, to the actions.
- return Actions.ActOnStringLiteral(getCurScope(), &StringToks[0],
- StringToks.size());
+ return Actions.ActOnStringLiteral(&StringToks[0], StringToks.size());
}
/// ParseExpressionList - Used for C/C++ (argument-)expression-list.
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Aug 30 12:47:05 2010
@@ -1244,12 +1244,11 @@
Tok.isNot(tok::eof));
}
Token t;
- t.startToken();
t.setKind(tok::string_literal);
t.setLiteralData("\"/*FIXME: not done*/\"");
t.clearFlag(Token::NeedsCleaning);
t.setLength(21);
- ExprResult AsmString(Actions.ActOnStringLiteral(getCurScope(), &t, 1));
+ ExprResult AsmString(Actions.ActOnStringLiteral(&t, 1));
ExprVector Constraints(Actions);
ExprVector Exprs(Actions);
ExprVector Clobbers(Actions);
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Aug 30 12:47:05 2010
@@ -5932,9 +5932,6 @@
return true;
}
- if (FnDecl->getDeclName().getCXXLiteralIdentifier()->getName()[0] != '_')
- Diag(FnDecl->getLocation(), diag::warn_literal_operator_no_underscore);
-
bool Valid = false;
// template <char...> type operator "" name() is the only valid template
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Aug 30 12:47:05 2010
@@ -375,8 +375,7 @@
/// string.
///
ExprResult
-Sema::ActOnStringLiteral(Scope *S, const Token *StringToks,
- unsigned NumStringToks) {
+Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) {
assert(NumStringToks && "Must have at least one string!");
StringLiteralParser Literal(StringToks, NumStringToks, PP);
@@ -402,18 +401,12 @@
llvm::APInt(32, Literal.GetNumStringChars()+1),
ArrayType::Normal, 0);
- StringLiteral *SL = StringLiteral::Create(Context, Literal.GetString(),
- Literal.GetStringLength(),
- Literal.AnyWide, StrTy,
- &StringTokLocs[0],
- StringTokLocs.size());
-
- if (Literal.isUserDefinedLiteral())
- return BuildUDStringLiteralExpr(S, SL, Literal.GetNumStringChars(),
- Literal.getUDSuffix());
-
// Pass &StringTokLocs[0], StringTokLocs.size() to factory!
- return Owned(SL);
+ return Owned(StringLiteral::Create(Context, Literal.GetString(),
+ Literal.GetStringLength(),
+ Literal.AnyWide, StrTy,
+ &StringTokLocs[0],
+ StringTokLocs.size()));
}
/// ShouldSnapshotBlockValueReference - Return true if a reference inside of
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Aug 30 12:47:05 2010
@@ -3057,61 +3057,3 @@
if (!FullExpr) return ExprError();
return MaybeCreateCXXExprWithTemporaries(FullExpr);
}
-
-ExprResult Sema::BuildUDStringLiteralExpr(Scope *S, StringLiteral *SL,
- unsigned L, IdentifierInfo *II) {
- DeclarationName DN = Context.DeclarationNames.getCXXLiteralOperatorName(II);
-
- LookupResult R(*this, DN, SL->getLocStart(), LookupOrdinaryName);
- LookupName(R, S);
-
- llvm::APInt APL(Context.getTypeSize(Context.getSizeType()), L);
-
- Expr *Args[2];
- Args[0] = SL;
- Args[1] = new (Context) IntegerLiteral(Context, APL, Context.getSizeType(),
- SourceLocation());
-
- OverloadCandidateSet CandidateSet(SL->getLocStart());
- AddFunctionCandidates(R.asUnresolvedSet(), Args, 2, CandidateSet);
- OverloadCandidateSet::iterator Best;
- switch (CandidateSet.BestViableFunction(*this, SL->getLocStart(), Best)) {
- case OR_Ambiguous:
- llvm_unreachable("UD literals should not have ambiguous overloads");
- return ExprError();
- case OR_No_Viable_Function:
- Diag(SL->getLocStart(), diag::err_literal_operator_overload)
- << SL->getSourceRange() << II->getName();
- return ExprError();
- case OR_Deleted:
- Diag(SL->getLocStart(), diag::err_literal_operator_deleted)
- << SL->getSourceRange() << II->getName();
- //FIXME: Note the deleted function
- return ExprError();
- case OR_Success:
- break;
- }
-
- assert(Best->Function && "Literal operator function not a real function");
- FunctionDecl *FD = Best->Function;
-
- ExprResult InputInit
- = PerformCopyInitialization(InitializedEntity::InitializeParameter(
- FD->getParamDecl(0)),
- SourceLocation(), Owned(SL));
- if (InputInit.isInvalid())
- return ExprError();
- Args[0] = InputInit.takeAs<Expr>();
-
- QualType ResultTy = FD->getResultType().getNonReferenceType();
- Expr *Fn = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
- UsualUnaryConversions(Fn);
-
- UDLiteralExpr *E = new (Context) UDLiteralExpr(Context, SL, Fn, Args, 2,
- ResultTy);
-
- if (CheckCallReturnType(FD->getResultType(), SL->getLocStart(), E, FD))
- return ExprError();
-
- return MaybeBindToTemporary(E);
-}
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 30 12:47:05 2010
@@ -6030,12 +6030,6 @@
template<typename Derived>
ExprResult
-TreeTransform<Derived>::TransformUDLiteralExpr(UDLiteralExpr *E) {
- return SemaRef.Owned(E->Retain());
-}
-
-template<typename Derived>
-ExprResult
TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
// Transform arguments.
bool ArgChanged = false;
Modified: cfe/trunk/test/Parser/cxx0x-literal-operators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-literal-operators.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-literal-operators.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-literal-operators.cpp Mon Aug 30 12:47:05 2010
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
void operator "" (const char *); // expected-error {{expected identifier}}
-void operator "k" _foo(const char *); // expected-error {{string literal after 'operator' must be '""'}}
-void operator "" _tester (const char *);
+void operator "k" foo(const char *); // expected-error {{string literal after 'operator' must be '""'}}
+void operator "" tester (const char *);
Removed: cfe/trunk/test/SemaCXX/literal-operator-dcls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/literal-operator-dcls.cpp?rev=112492&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/literal-operator-dcls.cpp (original)
+++ cfe/trunk/test/SemaCXX/literal-operator-dcls.cpp (removed)
@@ -1,46 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
-
-#include <stddef.h>
-
-struct tag {
- void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator "" _tag_bad' must be in a namespace or global scope}}
- friend void operator "" _tag_good (const char *);
-};
-
-namespace ns { void operator "" _ns_good (const char *); }
-
-// Check extern "C++" declarations
-extern "C++" void operator "" _extern_good (const char *);
-extern "C++" { void operator "" _extern_good (const char *); }
-
-void fn () { void operator "" _fn_bad (const char *); } // expected-error {{literal operator 'operator "" _fn_bad' must be in a namespace or global scope}}
-
-// Warning name
-void operator "" warn (const char *); // expected-warning {{reserved for future standardization}}
-
-// One-param declarations (const char * was already checked)
-void operator "" _good (char);
-void operator "" _good (wchar_t);
-void operator "" _good (char16_t);
-void operator "" _good (char32_t);
-void operator "" _good (unsigned long long);
-void operator "" _good (long double);
-
-// Two-param declarations
-void operator "" _good (const char *, size_t);
-void operator "" _good (const wchar_t *, size_t);
-void operator "" _good (const char16_t *, size_t);
-void operator "" _good (const char32_t *, size_t);
-
-// Check typedef and array equivalences
-void operator "" _good (const char[]);
-typedef const char c;
-void operator "" _good (c*);
-
-// Check extra cv-qualifiers
-void operator "" _cv_good (volatile const char *, const size_t);
-
-// Template delcaration (not implemented yet)
-// template <char...> void operator "" good ();
-
-// FIXME: Test some invalid decls that might crop up.
Modified: cfe/trunk/test/SemaCXX/literal-operators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/literal-operators.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/literal-operators.cpp (original)
+++ cfe/trunk/test/SemaCXX/literal-operators.cpp Mon Aug 30 12:47:05 2010
@@ -2,21 +2,42 @@
#include <stddef.h>
-template <typename T, typename U> struct same_type {
- static const bool value = false;
+struct tag {
+ void operator "" tag_bad (const char *); // expected-error {{literal operator 'operator "" tag_bad' must be in a namespace or global scope}}
+ friend void operator "" tag_good (const char *);
};
-template <typename T> struct same_type<T, T> {
- static const bool value = true;
-};
-
-int operator "" _int (const char *, size_t);
-static_assert(same_type<int, decltype(""_int)>::value, "not the same type!");
+namespace ns { void operator "" ns_good (const char *); }
-int i = ""_int;
-int j = L""_int; // expected-error {{no matching literal operator function}}
+// Check extern "C++" declarations
+extern "C++" void operator "" extern_good (const char *);
+extern "C++" { void operator "" extern_good (const char *); }
+
+void fn () { void operator "" fn_bad (const char *); } // expected-error {{literal operator 'operator "" fn_bad' must be in a namespace or global scope}}
+
+// One-param declarations (const char * was already checked)
+void operator "" good (char);
+void operator "" good (wchar_t);
+void operator "" good (char16_t);
+void operator "" good (char32_t);
+void operator "" good (unsigned long long);
+void operator "" good (long double);
+
+// Two-param declarations
+void operator "" good (const char *, size_t);
+void operator "" good (const wchar_t *, size_t);
+void operator "" good (const char16_t *, size_t);
+void operator "" good (const char32_t *, size_t);
+
+// Check typedef and array equivalences
+void operator "" good (const char[]);
+typedef const char c;
+void operator "" good (c*);
-int operator "" _int (const wchar_t *, size_t);
+// Check extra cv-qualifiers
+void operator "" cv_good (volatile const char *, const size_t);
-int k = L""_int;
+// Template delcaration (not implemented yet)
+// template <char...> void operator "" good ();
+// FIXME: Test some invalid decls that might crop up.
Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=112493&r1=112492&r2=112493&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Mon Aug 30 12:47:05 2010
@@ -218,7 +218,6 @@
case Stmt::CXXMemberCallExprClass:
case Stmt::CXXConstructExprClass:
case Stmt::CXXTemporaryObjectExprClass:
- case Stmt::UDLiteralExprClass:
// FIXME: CXXUnresolvedConstructExpr
// FIXME: ObjCImplicitSetterGetterRefExpr?
K = CXCursor_CallExpr;
More information about the cfe-commits
mailing list