From 4c9b7dc92e22f58f7a621e72bb6a90d77d986ef3 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Sat, 5 Oct 2013 22:45:34 +0000 Subject: [PATCH] Switching the CallableWhen attribute over to using the string literal helper function instead of custom logic. llvm-svn: 192050 --- clang/lib/Sema/SemaDeclAttr.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 41cc3fd285a2..1985de4c1b28 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1059,25 +1059,19 @@ static void handleCallableWhenAttr(Sema &S, Decl *D, for (unsigned ArgIndex = 0; ArgIndex < Attr.getNumArgs(); ++ArgIndex) { CallableWhenAttr::ConsumedState CallableState; - if (Attr.isArgExpr(ArgIndex) && - isa(Attr.getArgAsExpr(ArgIndex))) { - - Expr *Arg = Attr.getArgAsExpr(ArgIndex); - StringRef StateString = cast(Arg)->getString(); - - if (!CallableWhenAttr::ConvertStrToConsumedState(StateString, - CallableState)) { - S.Diag(Arg->getExprLoc(), diag::warn_attribute_type_not_supported) - << Attr.getName() << StateString; - return; - } - - States.push_back(CallableState); - } else { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName() - << AANT_ArgumentString; + StringRef StateString; + SourceLocation Loc; + if (!S.checkStringLiteralArgumentAttr(Attr, ArgIndex, StateString, &Loc)) + return; + + if (!CallableWhenAttr::ConvertStrToConsumedState(StateString, + CallableState)) { + S.Diag(Loc, diag::warn_attribute_type_not_supported) + << Attr.getName() << StateString; return; } + + States.push_back(CallableState); } D->addAttr(::new (S.Context)