diff options
author | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2010-08-30 17:47:05 +0000 |
---|---|---|
committer | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2010-08-30 17:47:05 +0000 |
commit | 6cf750298d3621d8a10a6dd07fcee8e274b9d94d (patch) | |
tree | 2d4b62e04dd3a48b65398bcc56ecc383719fdad8 /lib | |
parent | 4a551000bee716ac8b1bbe16134a53f0ad221a5a (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 3 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 5 | ||||
-rw-r--r-- | lib/AST/StmtProfile.cpp | 6 | ||||
-rw-r--r-- | lib/Checker/GRExprEngine.cpp | 1 | ||||
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 1 | ||||
-rw-r--r-- | lib/Lex/Lexer.cpp | 31 | ||||
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 28 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 26 | ||||
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 3 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 19 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 58 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 6 |
15 files changed, 29 insertions, 167 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index d067668f4b..14cbbaf0e8 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2423,8 +2423,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { 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); diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 084bdb3ed6..ea528c2dae 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1199,11 +1199,6 @@ void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) { } } -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"); diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 79454748dd..098aec0a19 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -828,12 +828,6 @@ void StmtProfiler::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *S) { 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); } diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index 059749d16f..c9173aa92a 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -886,7 +886,6 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred, } 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); diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 0680428e90..dd881350c6 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -210,9 +210,6 @@ public: return CGF.EmitCallExpr(E).getScalarVal(); } - Value *VisitUDLiteralExpr(const UDLiteralExpr *E) { - return VisitCallExpr(E); - } Value *VisitStmtExpr(const StmtExpr *E); diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 51b07a1327..c06b4fc699 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1634,7 +1634,6 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { break; case Expr::CXXMemberCallExprClass: // fallthrough - case Expr::UDLiteralExprClass: case Expr::CallExprClass: { const CallExpr *CE = cast<CallExpr>(E); Out << "cl"; diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index dabc15951f..118b618f2a 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -548,11 +548,6 @@ static void InitCharacterInfo() { 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 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, bool Wide) { // 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); } diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index eb7337a565..a12c4ae0d4 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -758,38 +758,30 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end, /// 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 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks, // 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 @@ unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok, 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]; diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index f52d35494a..5160acf19e 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -352,25 +352,15 @@ std::string Preprocessor::getSpelling(const Token &Tok, bool *Invalid) const { /// 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 @@ unsigned Preprocessor::getSpelling(const Token &Tok, const char *&Buffer, } // 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; diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 2ade77a907..290b72c4c0 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -1568,8 +1568,7 @@ ExprResult Parser::ParseStringLiteralExpression() { } 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. diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 94b8c3baac..af927285a4 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1244,12 +1244,11 @@ StmtResult Parser::FuzzyParseMicrosoftAsmStatement() { 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); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 4abeaaf246..35920c2792 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5932,9 +5932,6 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { 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 diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 80500714f4..455730c909 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -375,8 +375,7 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr, /// 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 @@ Sema::ActOnStringLiteral(Scope *S, const Token *StringToks, 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 diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 344196cc6f..5720d931b6 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -3057,61 +3057,3 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FullExpr) { 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); -} diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 8784c844be..08cfd68d66 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -6030,12 +6030,6 @@ TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) { 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; |