summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-20 23:49:24 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-20 23:49:24 +0000
commit96d21d6fa5792981953b3d9ec749f34357338a0c (patch)
tree925402021b0a0b115c328bf7c942c64803026676 /llvm/lib/AsmParser
parent82ad78771b8c59c227e61e74330c0bcaa847d2ea (diff)
downloadbcm5719-llvm-96d21d6fa5792981953b3d9ec749f34357338a0c.tar.gz
bcm5719-llvm-96d21d6fa5792981953b3d9ec749f34357338a0c.zip
AsmParser: Use do{}while(false) in macros, NFC
`do { ... } while (false)` is standard macro etiquette for forcing instantiations into a single statement and requiring a `;` afterwards, making statement-like macros easier to reason about (and harder to use incorrectly). I'm about to modify the macros in `LexIdentifier()`. I noticed that the `KEYWORD` macro *does* follow the rule, so I thought I'd clean up the other macros to match (otherwise might not be worth changing, since the benefits of this pattern are fairly irrelevant here). llvm-svn: 230095
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r--llvm/lib/AsmParser/LLLexer.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index 2fd9861c517..7e0f92f3a9b 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -668,9 +668,13 @@ lltok::Kind LLLexer::LexIdentifier() {
#undef KEYWORD
// Keywords for types.
-#define TYPEKEYWORD(STR, LLVMTY) \
- if (Len == strlen(STR) && !memcmp(StartChar, STR, strlen(STR))) { \
- TyVal = LLVMTY; return lltok::Type; }
+#define TYPEKEYWORD(STR, LLVMTY) \
+ do { \
+ if (Len == strlen(STR) && !memcmp(StartChar, STR, strlen(STR))) { \
+ TyVal = LLVMTY; \
+ return lltok::Type; \
+ } \
+ } while (false)
TYPEKEYWORD("void", Type::getVoidTy(Context));
TYPEKEYWORD("half", Type::getHalfTy(Context));
TYPEKEYWORD("float", Type::getFloatTy(Context));
@@ -684,9 +688,13 @@ lltok::Kind LLLexer::LexIdentifier() {
#undef TYPEKEYWORD
// Keywords for instructions.
-#define INSTKEYWORD(STR, Enum) \
- if (Len == strlen(#STR) && !memcmp(StartChar, #STR, strlen(#STR))) { \
- UIntVal = Instruction::Enum; return lltok::kw_##STR; }
+#define INSTKEYWORD(STR, Enum) \
+ do { \
+ if (Len == strlen(#STR) && !memcmp(StartChar, #STR, strlen(#STR))) { \
+ UIntVal = Instruction::Enum; \
+ return lltok::kw_##STR; \
+ } \
+ } while (false)
INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
@@ -739,11 +747,13 @@ lltok::Kind LLLexer::LexIdentifier() {
#undef INSTKEYWORD
#define DWKEYWORD(TYPE, TOKEN) \
- if (Len >= strlen("DW_" #TYPE "_") && \
- !memcmp(StartChar, "DW_" #TYPE "_", strlen("DW_" #TYPE "_"))) { \
- StrVal.assign(StartChar, CurPtr); \
- return lltok::TOKEN; \
- }
+ do { \
+ if (Len >= strlen("DW_" #TYPE "_") && \
+ !memcmp(StartChar, "DW_" #TYPE "_", strlen("DW_" #TYPE "_"))) { \
+ StrVal.assign(StartChar, CurPtr); \
+ return lltok::TOKEN; \
+ } \
+ } while (false)
DWKEYWORD(TAG, DwarfTag);
DWKEYWORD(ATE, DwarfAttEncoding);
DWKEYWORD(VIRTUALITY, DwarfVirtuality);
OpenPOWER on IntegriCloud