diff options
author | Kaelyn Takata <rikka@google.com> | 2014-10-27 18:07:29 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2014-10-27 18:07:29 +0000 |
commit | 89c881b548753639e4abf8a6edf30edf22190275 (patch) | |
tree | 278309f84e85ce671e0f18e9901c67b3cb79fb0c /clang/lib/Parse | |
parent | e1f49d545dbbf02c77dc297551101eab58cb2485 (diff) | |
download | bcm5719-llvm-89c881b548753639e4abf8a6edf30edf22190275.tar.gz bcm5719-llvm-89c881b548753639e4abf8a6edf30edf22190275.zip |
Pass around CorrectionCandidateCallbacks as unique_ptrs so
TypoCorrectionConsumer can keep the callback around as long as needed.
llvm-svn: 220693
Diffstat (limited to 'clang/lib/Parse')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Parse/ParseTentative.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 8 |
4 files changed, 15 insertions, 15 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 4489b94215e..60840c6f510 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -883,13 +883,13 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, UnqualifiedId Name; CXXScopeSpec ScopeSpec; SourceLocation TemplateKWLoc; - CastExpressionIdValidator Validator(isTypeCast != NotTypeCast, - isTypeCast != IsTypeCast); - Validator.IsAddressOfOperand = isAddressOfOperand; + auto Validator = llvm::make_unique<CastExpressionIdValidator>( + isTypeCast != NotTypeCast, isTypeCast != IsTypeCast); + Validator->IsAddressOfOperand = isAddressOfOperand; Name.setIdentifier(&II, ILoc); Res = Actions.ActOnIdExpression(getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren), - isAddressOfOperand, &Validator); + isAddressOfOperand, std::move(Validator)); break; } case tok::char_constant: // constant: character-constant diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index cf689998ea8..3bf66c3f2e3 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -185,9 +185,9 @@ Retry: if (Next.isNot(tok::coloncolon)) { // Try to limit which sets of keywords should be included in typo // correction based on what the next token is. - StatementFilterCCC Validator(Next); - if (TryAnnotateName(/*IsAddressOfOperand*/false, &Validator) - == ANK_Error) { + if (TryAnnotateName(/*IsAddressOfOperand*/ false, + llvm::make_unique<StatementFilterCCC>(Next)) == + ANK_Error) { // Handle errors here by skipping up to the next semicolon or '}', and // eat the semicolon if that's what stopped us. SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch); diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index 8463138e852..4b1375dfc18 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -1131,14 +1131,14 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, // a parse error one way or another. In that case, tell the caller that // this is ambiguous. Typo-correct to type and expression keywords and // to types and identifiers, in order to try to recover from errors. - CorrectionCandidateCallback TypoCorrection; - TypoCorrection.WantRemainingKeywords = false; - TypoCorrection.WantTypeSpecifiers = + auto TypoCorrection = llvm::make_unique<CorrectionCandidateCallback>(); + TypoCorrection->WantRemainingKeywords = false; + TypoCorrection->WantTypeSpecifiers = Next.is(tok::l_paren) || Next.is(tok::r_paren) || Next.is(tok::greater) || Next.is(tok::l_brace) || Next.is(tok::identifier); switch (TryAnnotateName(false /* no nested name specifier */, - &TypoCorrection)) { + std::move(TypoCorrection))) { case ANK_Error: return TPResult::Error; case ANK_TentativeDecl: diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 93e893e723b..90d2815b4f8 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1327,7 +1327,7 @@ void Parser::AnnotateScopeToken(CXXScopeSpec &SS, bool IsNewAnnotation) { /// no typo correction will be performed. Parser::AnnotatedNameKind Parser::TryAnnotateName(bool IsAddressOfOperand, - CorrectionCandidateCallback *CCC) { + std::unique_ptr<CorrectionCandidateCallback> CCC) { assert(Tok.is(tok::identifier) || Tok.is(tok::annot_cxxscope)); const bool EnteringContext = false; @@ -1365,9 +1365,9 @@ Parser::TryAnnotateName(bool IsAddressOfOperand, // after a scope specifier, because in general we can't recover from typos // there (eg, after correcting 'A::tempalte B<X>::C' [sic], we would need to // jump back into scope specifier parsing). - Sema::NameClassification Classification - = Actions.ClassifyName(getCurScope(), SS, Name, NameLoc, Next, - IsAddressOfOperand, SS.isEmpty() ? CCC : nullptr); + Sema::NameClassification Classification = Actions.ClassifyName( + getCurScope(), SS, Name, NameLoc, Next, IsAddressOfOperand, + SS.isEmpty() ? std::move(CCC) : nullptr); switch (Classification.getKind()) { case Sema::NC_Error: |