r192050 - Switching the CallableWhen attribute over to using the string literal helper function instead of custom logic.
Aaron Ballman
aaron at aaronballman.com
Sat Oct 5 15:45:34 PDT 2013
Author: aaronballman
Date: Sat Oct 5 17:45:34 2013
New Revision: 192050
URL: http://llvm.org/viewvc/llvm-project?rev=192050&view=rev
Log:
Switching the CallableWhen attribute over to using the string literal helper function instead of custom logic.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=192050&r1=192049&r2=192050&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Oct 5 17:45:34 2013
@@ -1059,25 +1059,19 @@ static void handleCallableWhenAttr(Sema
for (unsigned ArgIndex = 0; ArgIndex < Attr.getNumArgs(); ++ArgIndex) {
CallableWhenAttr::ConsumedState CallableState;
- if (Attr.isArgExpr(ArgIndex) &&
- isa<StringLiteral>(Attr.getArgAsExpr(ArgIndex))) {
-
- Expr *Arg = Attr.getArgAsExpr(ArgIndex);
- StringRef StateString = cast<StringLiteral>(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)
More information about the cfe-commits
mailing list