diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-08-18 17:56:27 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-08-18 17:56:27 +0000 |
commit | 61a72d88506cbb0b7067bb8176028fe61700b5ed (patch) | |
tree | afc1d24011b63e558f492b54ab75b14e58696e65 /llvm/lib/AsmParser/LLLexer.cpp | |
parent | fa5ca2bf4677d440eb15dcb851b39a31851c1164 (diff) | |
download | bcm5719-llvm-61a72d88506cbb0b7067bb8176028fe61700b5ed.tar.gz bcm5719-llvm-61a72d88506cbb0b7067bb8176028fe61700b5ed.zip |
[LLVM] Fix some Clang-tidy modernize-use-using and Include What You Use warnings
Differential revision: https://reviews.llvm.org/D23675
llvm-svn: 279102
Diffstat (limited to 'llvm/lib/AsmParser/LLLexer.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 9cd21e75a7b..58fe13e0249 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -12,21 +12,18 @@ //===----------------------------------------------------------------------===// #include "LLLexer.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" -#include "llvm/AsmParser/Parser.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instruction.h" -#include "llvm/IR/LLVMContext.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MathExtras.h" -#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" -#include "llvm/Support/raw_ostream.h" +#include <cassert> #include <cctype> #include <cstdio> -#include <cstdlib> -#include <cstring> + using namespace llvm; bool LLLexer::Error(LocTy ErrorLoc, const Twine &Msg) const { @@ -147,18 +144,15 @@ static bool isLabelChar(char C) { C == '.' || C == '_'; } - /// isLabelTail - Return true if this pointer points to a valid end of a label. static const char *isLabelTail(const char *CurPtr) { - while (1) { + while (true) { if (CurPtr[0] == ':') return CurPtr+1; if (!isLabelChar(CurPtr[0])) return nullptr; ++CurPtr; } } - - //===----------------------------------------------------------------------===// // Lexer definition. //===----------------------------------------------------------------------===// @@ -185,7 +179,6 @@ int LLLexer::getNextChar() { } } - lltok::Kind LLLexer::LexToken() { TokStart = CurPtr; @@ -246,7 +239,7 @@ lltok::Kind LLLexer::LexToken() { } void LLLexer::SkipLineComment() { - while (1) { + while (true) { if (CurPtr[0] == '\n' || CurPtr[0] == '\r' || getNextChar() == EOF) return; } @@ -271,7 +264,7 @@ lltok::Kind LLLexer::LexDollar() { if (CurPtr[0] == '"') { ++CurPtr; - while (1) { + while (true) { int CurChar = getNextChar(); if (CurChar == EOF) { @@ -300,7 +293,7 @@ lltok::Kind LLLexer::LexDollar() { /// ReadString - Read a string until the closing quote. lltok::Kind LLLexer::ReadString(lltok::Kind kind) { const char *Start = CurPtr; - while (1) { + while (true) { int CurChar = getNextChar(); if (CurChar == EOF) { @@ -338,7 +331,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) { if (CurPtr[0] == '"') { ++CurPtr; - while (1) { + while (true) { int CurChar = getNextChar(); if (CurChar == EOF) { @@ -488,11 +481,12 @@ lltok::Kind LLLexer::LexIdentifier() { CurPtr = KeywordEnd; --StartChar; StringRef Keyword(StartChar, CurPtr - StartChar); + #define KEYWORD(STR) \ do { \ if (Keyword == #STR) \ return lltok::kw_##STR; \ - } while (0) + } while (false) KEYWORD(true); KEYWORD(false); KEYWORD(declare); KEYWORD(define); @@ -697,6 +691,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(cleanup); KEYWORD(catch); KEYWORD(filter); + #undef KEYWORD // Keywords for types. @@ -707,6 +702,7 @@ lltok::Kind LLLexer::LexIdentifier() { return lltok::Type; \ } \ } while (false) + TYPEKEYWORD("void", Type::getVoidTy(Context)); TYPEKEYWORD("half", Type::getHalfTy(Context)); TYPEKEYWORD("float", Type::getFloatTy(Context)); @@ -718,6 +714,7 @@ lltok::Kind LLLexer::LexIdentifier() { TYPEKEYWORD("metadata", Type::getMetadataTy(Context)); TYPEKEYWORD("x86_mmx", Type::getX86_MMXTy(Context)); TYPEKEYWORD("token", Type::getTokenTy(Context)); + #undef TYPEKEYWORD // Keywords for instructions. @@ -782,6 +779,7 @@ lltok::Kind LLLexer::LexIdentifier() { INSTKEYWORD(catchswitch, CatchSwitch); INSTKEYWORD(catchpad, CatchPad); INSTKEYWORD(cleanuppad, CleanupPad); + #undef INSTKEYWORD #define DWKEYWORD(TYPE, TOKEN) \ @@ -791,6 +789,7 @@ lltok::Kind LLLexer::LexIdentifier() { return lltok::TOKEN; \ } \ } while (false) + DWKEYWORD(TAG, DwarfTag); DWKEYWORD(ATE, DwarfAttEncoding); DWKEYWORD(VIRTUALITY, DwarfVirtuality); @@ -798,7 +797,9 @@ lltok::Kind LLLexer::LexIdentifier() { DWKEYWORD(CC, DwarfCC); DWKEYWORD(OP, DwarfOp); DWKEYWORD(MACINFO, DwarfMacinfo); + #undef DWKEYWORD + if (Keyword.startswith("DIFlag")) { StrVal.assign(Keyword.begin(), Keyword.end()); return lltok::DIFlag; |