diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 443d8be92b92..f176041bf17a 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -1613,7 +1613,7 @@ public: /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "sizeof" or "[pre]++" - static const char *getOpcodeStr(Opcode Op); + static StringRef getOpcodeStr(Opcode Op); /// \brief Retrieve the unary opcode that corresponds to the given /// overloaded operator. @@ -2836,9 +2836,9 @@ public: /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "<<=". - static const char *getOpcodeStr(Opcode Op); + static StringRef getOpcodeStr(Opcode Op); - const char *getOpcodeStr() const { return getOpcodeStr(getOpcode()); } + StringRef getOpcodeStr() const { return getOpcodeStr(getOpcode()); } /// \brief Retrieve the binary opcode that corresponds to the given /// overloaded operator. diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h index 85ef77af9334..6ebccbdba638 100644 --- a/clang/include/clang/Sema/Overload.h +++ b/clang/include/clang/Sema/Overload.h @@ -808,7 +808,7 @@ namespace clang { void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, llvm::ArrayRef Args, - const char *Opc = 0, + StringRef Opc = "", SourceLocation Loc = SourceLocation()); }; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index e1198b85c5a5..694325af22d7 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -869,7 +869,7 @@ getLocationOfByte(unsigned ByteNo, const SourceManager &SM, /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "sizeof" or "[pre]++". -const char *UnaryOperator::getOpcodeStr(Opcode Op) { +StringRef UnaryOperator::getOpcodeStr(Opcode Op) { switch (Op) { case UO_PostInc: return "++"; case UO_PostDec: return "--"; @@ -1570,7 +1570,7 @@ CStyleCastExpr *CStyleCastExpr::CreateEmpty(ASTContext &C, unsigned PathSize) { /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "<<=". -const char *BinaryOperator::getOpcodeStr(Opcode Op) { +StringRef BinaryOperator::getOpcodeStr(Opcode Op) { switch (Op) { case BO_PtrMemD: return ".*"; case BO_PtrMemI: return "->*"; diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 67d290b73c5e..6d09f2c116f3 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -501,7 +501,7 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use, // Information used when building the diagnostic. unsigned DiagKind; - const char *Str; + StringRef Str; SourceRange Range; // FixIts to suppress the diagnosic by removing the dead condition. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d40818b83b0d..dcb3736bd7b5 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8464,8 +8464,8 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceRange DiagRange = isLeftComp ? SourceRange(LHSExpr->getLocStart(), OpLoc) : SourceRange(OpLoc, RHSExpr->getLocEnd()); - std::string OpStr = isLeftComp ? BinOp::getOpcodeStr(LHSopc) - : BinOp::getOpcodeStr(RHSopc); + StringRef OpStr = isLeftComp ? BinOp::getOpcodeStr(LHSopc) + : BinOp::getOpcodeStr(RHSopc); SourceRange ParensRange = isLeftComp ? SourceRange(cast(LHSExpr)->getRHS()->getLocStart(), RHSExpr->getLocEnd()) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 10b96c9ec310..600393137d72 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -8537,7 +8537,7 @@ void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand) { } void NoteBuiltinOperatorCandidate(Sema &S, - const char *Opc, + StringRef Opc, SourceLocation OpLoc, OverloadCandidate *Cand) { assert(Cand->NumConversions <= 2 && "builtin operator is not binary"); @@ -8806,7 +8806,7 @@ void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, void OverloadCandidateSet::NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, llvm::ArrayRef Args, - const char *Opc, + StringRef Opc, SourceLocation OpLoc) { // Sort the candidates by viability and position. Sorting directly would // be prohibitive, so we make a set of pointers and sort those.