[llvm] r343010 - [MC] Fix bad indentation and 80 column violations. Use StringRef::front instead of dereferencing StringRef::begin. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 25 12:37:35 PDT 2018
Author: ctopper
Date: Tue Sep 25 12:37:35 2018
New Revision: 343010
URL: http://llvm.org/viewvc/llvm-project?rev=343010&view=rev
Log:
[MC] Fix bad indentation and 80 column violations. Use StringRef::front instead of dereferencing StringRef::begin. NFC
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=343010&r1=343009&r2=343010&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Sep 25 12:37:35 2018
@@ -1323,8 +1323,9 @@ AsmParser::applyModifierToExpr(const MCE
/// 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_
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(cons
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()) {
More information about the llvm-commits
mailing list