diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-11-10 20:43:52 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-11-10 20:43:52 +0000 |
commit | a19ea3454dd2d3d0daa44f93672cf4cd722b6a2c (patch) | |
tree | 037bfbe0fb3ea83d2df6e00057bc7b80344073b9 /clang/lib | |
parent | f47c3bb8dbcdba2f76a66ba8937bb34953998295 (diff) | |
download | bcm5719-llvm-a19ea3454dd2d3d0daa44f93672cf4cd722b6a2c.tar.gz bcm5719-llvm-a19ea3454dd2d3d0daa44f93672cf4cd722b6a2c.zip |
Clean up uses of unique_ptr for RAII objects. NFC.
- EnterExpressionEvaluationContext allows you to specify whether you
*actually* want to enter an evaluation context.
- For types that don't allow that, llvm::Optional<Foo> should do the
same thing as std::unique_ptr<Foo>, but with 100% less heap
allocations.
llvm-svn: 286500
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index f36e9dfdc44..ea942eb69a9 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -25,6 +25,7 @@ #include "clang/Sema/PrettyDeclStackTrace.h" #include "clang/Sema/Scope.h" #include "clang/Sema/SemaDiagnostic.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" @@ -301,10 +302,10 @@ unsigned Parser::ParseAttributeArgsCommon( // Parse the non-empty comma-separated list of expressions. do { - std::unique_ptr<EnterExpressionEvaluationContext> Unevaluated; - if (attributeParsedArgsUnevaluated(*AttrName)) - Unevaluated.reset( - new EnterExpressionEvaluationContext(Actions, Sema::Unevaluated)); + bool ShouldEnter = attributeParsedArgsUnevaluated(*AttrName); + EnterExpressionEvaluationContext Unevaluated( + Actions, Sema::Unevaluated, /*LambdaContextDecl=*/nullptr, + /*IsDecltype=*/false, ShouldEnter); ExprResult ArgExpr( Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression())); @@ -366,13 +367,13 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, // These may refer to the function arguments, but need to be parsed early to // participate in determining whether it's a redeclaration. - std::unique_ptr<ParseScope> PrototypeScope; + llvm::Optional<ParseScope> PrototypeScope; if (normalizeAttrName(AttrName->getName()) == "enable_if" && D && D->isFunctionDeclarator()) { DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo(); - PrototypeScope.reset(new ParseScope(this, Scope::FunctionPrototypeScope | - Scope::FunctionDeclarationScope | - Scope::DeclScope)); + PrototypeScope.emplace(this, Scope::FunctionPrototypeScope | + Scope::FunctionDeclarationScope | + Scope::DeclScope); for (unsigned i = 0; i != FTI.NumParams; ++i) { ParmVarDecl *Param = cast<ParmVarDecl>(FTI.Params[i].Param); Actions.ActOnReenterCXXMethodParameter(getCurScope(), Param); |