r266827 - [Parse] Use StringSwitch to improve readability. NFC
Adam Nemet via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 19 15:17:45 PDT 2016
Author: anemet
Date: Tue Apr 19 17:17:45 2016
New Revision: 266827
URL: http://llvm.org/viewvc/llvm-project?rev=266827&view=rev
Log:
[Parse] Use StringSwitch to improve readability. NFC
A subsequent patch will propose a "distribute" loop hint. Similarly to
unroll, this does not have a "assume_safety" argument either so this
condition will get more complex.
Modified:
cfe/trunk/lib/Parse/ParsePragma.cpp
Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=266827&r1=266826&r2=266827&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Tue Apr 19 17:17:45 2016
@@ -841,10 +841,14 @@ bool Parser::HandlePragmaLoopHint(LoopHi
ConsumeToken(); // The annotation token.
SourceLocation StateLoc = Toks[0].getLocation();
IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
- if (!StateInfo ||
- (!StateInfo->isStr("enable") && !StateInfo->isStr("disable") &&
- ((OptionUnroll && !StateInfo->isStr("full")) ||
- (!OptionUnroll && !StateInfo->isStr("assume_safety"))))) {
+
+ bool Valid = StateInfo &&
+ llvm::StringSwitch<bool>(StateInfo->getName())
+ .Cases("enable", "disable", true)
+ .Case("full", OptionUnroll)
+ .Case("assume_safety", !OptionUnroll)
+ .Default(false);
+ if (!Valid) {
Diag(Toks[0].getLocation(), diag::err_pragma_invalid_keyword)
<< /*FullKeyword=*/OptionUnroll;
return false;
More information about the cfe-commits
mailing list