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/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index d067668..14cbbaf 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -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);
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 084bdb3..ea528c2 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -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");
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 7945474..098aec0 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -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);
 }
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index 059749d..c9173aa 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -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);
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 0680428..dd88135 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -210,9 +210,6 @@
 
     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 51b07a1..c06b4fc 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -1634,7 +1634,6 @@
     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 dabc159..118b618 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -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);
 }
 
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index eb7337a..a12c4ae 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -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];
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index f52d354..5160acf 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -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;
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 2ade77a..290b72c 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -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.
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 94b8c3b..af92728 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -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);
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 4abeaaf..35920c2 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -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
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 8050071..455730c 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 344196c..5720d93 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -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);
-}
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 8784c84..08cfd68 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -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;