diff options
author | Craig Topper <craig.topper@intel.com> | 2018-09-25 19:37:35 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-09-25 19:37:35 +0000 |
commit | 3da977be134f4d753a5ee556a2b043e69b924b8e (patch) | |
tree | feec72ee96274f764cf9884f442bf704d70064c0 | |
parent | 4e247522ac8dc1ee1046df2c54c84e6bcc2bc1a9 (diff) | |
download | bcm5719-llvm-3da977be134f4d753a5ee556a2b043e69b924b8e.tar.gz bcm5719-llvm-3da977be134f4d753a5ee556a2b043e69b924b8e.zip |
[MC] Fix bad indentation and 80 column violations. Use StringRef::front instead of dereferencing StringRef::begin. NFC
llvm-svn: 343010
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 4d4ea97f372..25bd480eedb 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -1323,8 +1323,9 @@ AsmParser::applyModifierToExpr(const MCExpr *E, /// the End argument will be filled with the last location pointed to the '>' /// character. -/// There is a gap between the AltMacro's documentation and the single quote implementation. -/// GCC does not fully support this feature and so we will not support it. +/// There is a gap between the AltMacro's documentation and the single quote +/// implementation. GCC does not fully support this feature and so we will not +/// support it. /// TODO: Adding single quote as a string. bool AsmParser::isAltmacroString(SMLoc &StrLoc, SMLoc &EndLoc) { assert((StrLoc.getPointer() != nullptr) && @@ -2437,17 +2438,19 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body, for (const AsmToken &Token : A[Index]) // For altmacro mode, you can write '%expr'. // The prefix '%' evaluates the expression 'expr' - // and uses the result as a string (e.g. replace %(1+2) with the string "3"). + // and uses the result as a string (e.g. replace %(1+2) with the + // string "3"). // Here, we identify the integer token which is the result of the - // absolute expression evaluation and replace it with its string representation. - if ((Lexer.IsaAltMacroMode()) && - (*(Token.getString().begin()) == '%') && Token.is(AsmToken::Integer)) + // absolute expression evaluation and replace it with its string + // representation. + if (Lexer.IsaAltMacroMode() && Token.getString().front() == '%' && + Token.is(AsmToken::Integer)) // Emit an integer value to the buffer. OS << Token.getIntVal(); // Only Token that was validated as a string and begins with '<' // is considered altMacroString!!! - else if ((Lexer.IsaAltMacroMode()) && - (*(Token.getString().begin()) == '<') && + else if (Lexer.IsaAltMacroMode() && + Token.getString().front() == '<' && Token.is(AsmToken::String)) { std::string Res; altMacroString(Token.getStringContents(), Res); @@ -2634,30 +2637,32 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M, SMLoc StrLoc = Lexer.getLoc(); SMLoc EndLoc; if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Percent)) { - const MCExpr *AbsoluteExp; - int64_t Value; - /// Eat '%' - Lex(); - if (parseExpression(AbsoluteExp, EndLoc)) - return false; - if (!AbsoluteExp->evaluateAsAbsolute(Value, - getStreamer().getAssemblerPtr())) - return Error(StrLoc, "expected absolute expression"); - const char *StrChar = StrLoc.getPointer(); - const char *EndChar = EndLoc.getPointer(); - AsmToken newToken(AsmToken::Integer, StringRef(StrChar , EndChar - StrChar), Value); - FA.Value.push_back(newToken); + const MCExpr *AbsoluteExp; + int64_t Value; + /// Eat '%' + Lex(); + if (parseExpression(AbsoluteExp, EndLoc)) + return false; + if (!AbsoluteExp->evaluateAsAbsolute(Value, + getStreamer().getAssemblerPtr())) + return Error(StrLoc, "expected absolute expression"); + const char *StrChar = StrLoc.getPointer(); + const char *EndChar = EndLoc.getPointer(); + AsmToken newToken(AsmToken::Integer, + StringRef(StrChar, EndChar - StrChar), Value); + FA.Value.push_back(newToken); } else if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Less) && isAltmacroString(StrLoc, EndLoc)) { - const char *StrChar = StrLoc.getPointer(); - const char *EndChar = EndLoc.getPointer(); - jumpToLoc(EndLoc, CurBuffer); - /// Eat from '<' to '>' - Lex(); - AsmToken newToken(AsmToken::String, StringRef(StrChar, EndChar - StrChar)); - FA.Value.push_back(newToken); + const char *StrChar = StrLoc.getPointer(); + const char *EndChar = EndLoc.getPointer(); + jumpToLoc(EndLoc, CurBuffer); + /// Eat from '<' to '>' + Lex(); + AsmToken newToken(AsmToken::String, + StringRef(StrChar, EndChar - StrChar)); + FA.Value.push_back(newToken); } else if(parseMacroArgument(FA.Value, Vararg)) - return true; + return true; unsigned PI = Parameter; if (!FA.Name.empty()) { |