mirror of https://github.com/microsoft/clang.git
Attributes accepting an EnumArgument are allowed to pass a string literal, or an identifier. VariadicEnumArguments now behave consistently instead of only accepting a string literal.
This change affects the only attribute accepting a variadic enumeration: callable_when. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce8220bf4f
commit
c77fbd026e
|
@ -863,8 +863,14 @@ static void handleCallableWhenAttr(Sema &S, Decl *D,
|
|||
|
||||
StringRef StateString;
|
||||
SourceLocation Loc;
|
||||
if (!S.checkStringLiteralArgumentAttr(Attr, ArgIndex, StateString, &Loc))
|
||||
return;
|
||||
if (Attr.isArgIdent(ArgIndex)) {
|
||||
IdentifierLoc *Ident = Attr.getArgAsIdent(ArgIndex);
|
||||
StateString = Ident->Ident->getName();
|
||||
Loc = Ident->Loc;
|
||||
} else {
|
||||
if (!S.checkStringLiteralArgumentAttr(Attr, ArgIndex, StateString, &Loc))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
|
||||
CallableState)) {
|
||||
|
|
|
@ -37,6 +37,7 @@ class CONSUMABLE(unknown) AttrTester1 {
|
|||
void callableWhen0() CALLABLE_WHEN("unconsumed");
|
||||
void callableWhen1() CALLABLE_WHEN(42); // expected-error {{'callable_when' attribute requires a string}}
|
||||
void callableWhen2() CALLABLE_WHEN("foo"); // expected-warning {{'callable_when' attribute argument not supported: foo}}
|
||||
void callableWhen3() CALLABLE_WHEN(unconsumed);
|
||||
void consumes() SET_TYPESTATE(consumed);
|
||||
bool testUnconsumed() TEST_TYPESTATE(consumed);
|
||||
};
|
||||
|
|
|
@ -1387,6 +1387,7 @@ static bool isIdentifierArgument(Record *Arg) {
|
|||
llvm::StringSwitch<bool>(Arg->getSuperClasses().back()->getName())
|
||||
.Case("IdentifierArgument", true)
|
||||
.Case("EnumArgument", true)
|
||||
.Case("VariadicEnumArgument", true)
|
||||
.Default(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue