Coverage Report

Created: 2018-11-13 17:19

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCParser/AsmLexer.h
Line
Count
Source
1
//===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This class declares the lexer for assembly files.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_MC_MCPARSER_ASMLEXER_H
15
#define LLVM_MC_MCPARSER_ASMLEXER_H
16
17
#include "llvm/ADT/StringRef.h"
18
#include "llvm/MC/MCParser/MCAsmLexer.h"
19
#include <string>
20
21
namespace llvm {
22
23
class MCAsmInfo;
24
25
/// AsmLexer - Lexer class for assembly files.
26
class AsmLexer : public MCAsmLexer {
27
  const MCAsmInfo &MAI;
28
29
  const char *CurPtr = nullptr;
30
  StringRef CurBuf;
31
  bool IsAtStartOfLine = true;
32
  bool IsAtStartOfStatement = true;
33
  bool IsPeeking = false;
34
35
protected:
36
  /// LexToken - Read the next token and return its code.
37
  AsmToken LexToken() override;
38
39
public:
40
  AsmLexer(const MCAsmInfo &MAI);
41
  AsmLexer(const AsmLexer &) = delete;
42
  AsmLexer &operator=(const AsmLexer &) = delete;
43
  ~AsmLexer() override;
44
45
  void setBuffer(StringRef Buf, const char *ptr = nullptr);
46
47
  StringRef LexUntilEndOfStatement() override;
48
49
  size_t peekTokens(MutableArrayRef<AsmToken> Buf,
50
                    bool ShouldSkipSpace = true) override;
51
52
1.32k
  const MCAsmInfo &getMAI() const { return MAI; }
53
54
private:
55
  bool isAtStartOfComment(const char *Ptr);
56
  bool isAtStatementSeparator(const char *Ptr);
57
  int getNextChar();
58
  AsmToken ReturnError(const char *Loc, const std::string &Msg);
59
60
  AsmToken LexIdentifier();
61
  AsmToken LexSlash();
62
  AsmToken LexLineComment();
63
  AsmToken LexDigit();
64
  AsmToken LexSingleQuote();
65
  AsmToken LexQuote();
66
  AsmToken LexFloatLiteral();
67
  AsmToken LexHexFloatLiteral(bool NoIntDigits);
68
69
  StringRef LexUntilEndOfLine();
70
};
71
72
} // end namespace llvm
73
74
#endif // LLVM_MC_MCPARSER_ASMLEXER_H