r192639 - Switching some custom logic to using table-generated helper methods. This also removes an unnecessary diagnostic.
Aaron Ballman
aaron at aaronballman.com
Mon Oct 14 16:22:37 PDT 2013
Author: aaronballman
Date: Mon Oct 14 18:22:37 2013
New Revision: 192639
URL: http://llvm.org/viewvc/llvm-project?rev=192639&view=rev
Log:
Switching some custom logic to using table-generated helper methods. This also removes an unnecessary diagnostic.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=192639&r1=192638&r2=192639&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 14 18:22:37 2013
@@ -2216,8 +2216,6 @@ def warn_attr_on_unconsumable_class : Wa
def warn_return_typestate_for_unconsumable_type : Warning<
"return state set for an unconsumable type '%0'">, InGroup<Consumed>,
DefaultIgnore;
-def warn_unknown_consumed_state : Warning<
- "unknown consumed analysis state '%0'">, InGroup<Consumed>, DefaultIgnore;
def warn_return_typestate_mismatch : Warning<
"return value not in expected state; expected '%0', observed '%1'">,
InGroup<Consumed>, DefaultIgnore;
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=192639&r1=192638&r2=192639&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 14 18:22:37 2013
@@ -1130,21 +1130,14 @@ static void handleSetTypestateAttr(Sema
return;
SetTypestateAttr::ConsumedState NewState;
-
if (Attr.isArgIdent(0)) {
- StringRef Param = Attr.getArgAsIdent(0)->Ident->getName();
-
- if (Param == "unknown") {
- NewState = SetTypestateAttr::Unknown;
- } else if (Param == "consumed") {
- NewState = SetTypestateAttr::Consumed;
- } else if (Param == "unconsumed") {
- NewState = SetTypestateAttr::Unconsumed;
- } else {
- S.Diag(Attr.getLoc(), diag::warn_unknown_consumed_state) << Param;
+ IdentifierLoc *Ident = Attr.getArgAsIdent(0);
+ StringRef Param = Ident->Ident->getName();
+ if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
+ S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
+ << Attr.getName() << Param;
return;
}
-
} else {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
Attr.getName() << AANT_ArgumentIdentifier;
@@ -1169,20 +1162,15 @@ static void handleTestsTypestateAttr(Sem
if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
return;
- TestsTypestateAttr::ConsumedState TestState;
-
+ TestsTypestateAttr::ConsumedState TestState;
if (Attr.isArgIdent(0)) {
- StringRef Param = Attr.getArgAsIdent(0)->Ident->getName();
-
- if (Param == "consumed") {
- TestState = TestsTypestateAttr::Consumed;
- } else if (Param == "unconsumed") {
- TestState = TestsTypestateAttr::Unconsumed;
- } else {
- S.Diag(Attr.getLoc(), diag::warn_unknown_consumed_state) << Param;
+ IdentifierLoc *Ident = Attr.getArgAsIdent(0);
+ StringRef Param = Ident->Ident->getName();
+ if (!TestsTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
+ S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
+ << Attr.getName() << Param;
return;
}
-
} else {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
Attr.getName() << AANT_ArgumentIdentifier;
More information about the cfe-commits
mailing list