[llvm] r283034 - Revert "[MC] Prevent out of order HashDirective lexing in AsmLexer."
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 1 03:57:55 PDT 2016
Author: niravd
Date: Sat Oct 1 05:57:55 2016
New Revision: 283034
URL: http://llvm.org/viewvc/llvm-project?rev=283034&view=rev
Log:
Revert "[MC] Prevent out of order HashDirective lexing in AsmLexer."
This reverts commit r282992 which appears to be causing an LTO test failure.
Removed:
llvm/trunk/test/MC/AsmParser/pr28921.s
Modified:
llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h
llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
Modified: llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h?rev=283034&r1=283033&r2=283034&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h Sat Oct 1 05:57:55 2016
@@ -32,7 +32,7 @@ class AsmLexer : public MCAsmLexer {
bool IsAtStartOfLine;
bool IsAtStartOfStatement;
bool IsParsingMSInlineAsm;
- bool IsPeeking;
+
void operator=(const AsmLexer&) = delete;
AsmLexer(const AsmLexer&) = delete;
Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=283034&r1=283033&r2=283034&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Sat Oct 1 05:57:55 2016
@@ -11,29 +11,29 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
-#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/SMLoc.h"
-#include "llvm/Support/SaveAndRestore.h"
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
-#include <string>
#include <tuple>
+#include <string>
#include <utility>
using namespace llvm;
-AsmLexer::AsmLexer(const MCAsmInfo &MAI)
- : MAI(MAI), CurPtr(nullptr), IsAtStartOfLine(true),
- IsAtStartOfStatement(true), IsParsingMSInlineAsm(false),
- IsPeeking(false) {
+AsmLexer::AsmLexer(const MCAsmInfo &MAI) : MAI(MAI) {
+ CurPtr = nullptr;
+ IsAtStartOfLine = true;
+ IsAtStartOfStatement = true;
+ IsParsingMSInlineAsm = false;
AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
}
@@ -487,15 +487,17 @@ StringRef AsmLexer::LexUntilEndOfLine()
size_t AsmLexer::peekTokens(MutableArrayRef<AsmToken> Buf,
bool ShouldSkipSpace) {
- SaveAndRestore<const char *> SavedTokenStart(TokStart);
- SaveAndRestore<const char *> SavedCurPtr(CurPtr);
- SaveAndRestore<bool> SavedAtStartOfLine(IsAtStartOfLine);
- SaveAndRestore<bool> SavedAtStartOfStatement(IsAtStartOfStatement);
- SaveAndRestore<bool> SavedSkipSpace(SkipSpace, ShouldSkipSpace);
- SaveAndRestore<bool> SavedIsPeeking(IsPeeking, true);
+ const char *SavedTokStart = TokStart;
+ const char *SavedCurPtr = CurPtr;
+ bool SavedAtStartOfLine = IsAtStartOfLine;
+ bool SavedAtStartOfStatement = IsAtStartOfStatement;
+ bool SavedSkipSpace = SkipSpace;
+
std::string SavedErr = getErr();
SMLoc SavedErrLoc = getErrLoc();
+ SkipSpace = ShouldSkipSpace;
+
size_t ReadCount;
for (ReadCount = 0; ReadCount < Buf.size(); ++ReadCount) {
AsmToken Token = LexToken();
@@ -507,6 +509,13 @@ size_t AsmLexer::peekTokens(MutableArray
}
SetError(SavedErrLoc, SavedErr);
+
+ SkipSpace = SavedSkipSpace;
+ IsAtStartOfLine = SavedAtStartOfLine;
+ IsAtStartOfStatement = SavedAtStartOfStatement;
+ CurPtr = SavedCurPtr;
+ TokStart = SavedTokStart;
+
return ReadCount;
}
@@ -516,7 +525,7 @@ bool AsmLexer::isAtStartOfComment(const
if (CommentString.size() == 1)
return CommentString[0] == Ptr[0];
- // Allow # preprocessor commments also be counted as comments for "##" cases
+ // FIXME: special case for the bogus "##" comment string in X86MCAsmInfoDarwin
if (CommentString[1] == '#')
return CommentString[0] == Ptr[0];
@@ -533,7 +542,7 @@ AsmToken AsmLexer::LexToken() {
// This always consumes at least one character.
int CurChar = getNextChar();
- if (!IsPeeking && CurChar == '#' && IsAtStartOfStatement) {
+ if (CurChar == '#' && IsAtStartOfStatement) {
// If this starts with a '#', this may be a cpp
// hash directive and otherwise a line comment.
AsmToken TokenBuf[2];
Removed: llvm/trunk/test/MC/AsmParser/pr28921.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/pr28921.s?rev=283033&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/pr28921.s (original)
+++ llvm/trunk/test/MC/AsmParser/pr28921.s (removed)
@@ -1,8 +0,0 @@
-// RUN: llvm-mc -triple i386-unknown-unknown %s
-
-# 1 "kernel.S"
-# 1 "<built-in>" 1
-# 1 "kernel.S" 2
-##
-# 10 "kernel.S"
-##
More information about the llvm-commits
mailing list