Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/AsmParser/LLLexer.h
Line
Count
Source (jump to first uncovered line)
1
//===- LLLexer.h - Lexer for LLVM 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 represents the Lexer for .ll files.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_LIB_ASMPARSER_LLLEXER_H
15
#define LLVM_LIB_ASMPARSER_LLLEXER_H
16
17
#include "LLToken.h"
18
#include "llvm/ADT/APFloat.h"
19
#include "llvm/ADT/APSInt.h"
20
#include "llvm/Support/SourceMgr.h"
21
#include <string>
22
23
namespace llvm {
24
  class MemoryBuffer;
25
  class Type;
26
  class SMDiagnostic;
27
  class LLVMContext;
28
29
  class LLLexer {
30
    const char *CurPtr;
31
    StringRef CurBuf;
32
    SMDiagnostic &ErrorInfo;
33
    SourceMgr &SM;
34
    LLVMContext &Context;
35
36
    // Information about the current token.
37
    const char *TokStart;
38
    lltok::Kind CurKind;
39
    std::string StrVal;
40
    unsigned UIntVal;
41
    Type *TyVal;
42
    APFloat APFloatVal;
43
    APSInt  APSIntVal;
44
45
  public:
46
    explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
47
                     LLVMContext &C);
48
49
20.1M
    lltok::Kind Lex() {
50
20.1M
      return CurKind = LexToken();
51
20.1M
    }
52
53
    typedef SMLoc LocTy;
54
15.9M
    LocTy getLoc() const { return SMLoc::getFromPointer(TokStart); }
55
38.8M
    lltok::Kind getKind() const { return CurKind; }
56
3.45M
    const std::string &getStrVal() const { return StrVal; }
57
3.41M
    Type *getTyVal() const { return TyVal; }
58
1.59M
    unsigned getUIntVal() const { return UIntVal; }
59
4.84M
    const APSInt &getAPSIntVal() const { return APSIntVal; }
60
39.5k
    const APFloat &getAPFloatVal() const { return APFloatVal; }
61
62
63
    bool Error(LocTy L, const Twine &Msg) const;
64
5
    bool Error(const Twine &Msg) const { return Error(getLoc(), Msg); }
65
66
    void Warning(LocTy WarningLoc, const Twine &Msg) const;
67
0
    void Warning(const Twine &Msg) const { return Warning(getLoc(), Msg); }
68
69
  private:
70
    lltok::Kind LexToken();
71
72
    int getNextChar();
73
    void SkipLineComment();
74
    lltok::Kind ReadString(lltok::Kind kind);
75
    bool ReadVarName();
76
77
    lltok::Kind LexIdentifier();
78
    lltok::Kind LexDigitOrNegative();
79
    lltok::Kind LexPositive();
80
    lltok::Kind LexAt();
81
    lltok::Kind LexDollar();
82
    lltok::Kind LexExclaim();
83
    lltok::Kind LexPercent();
84
    lltok::Kind LexVar(lltok::Kind Var, lltok::Kind VarID);
85
    lltok::Kind LexQuote();
86
    lltok::Kind Lex0x();
87
    lltok::Kind LexHash();
88
89
    uint64_t atoull(const char *Buffer, const char *End);
90
    uint64_t HexIntToVal(const char *Buffer, const char *End);
91
    void HexToIntPair(const char *Buffer, const char *End, uint64_t Pair[2]);
92
    void FP80HexToIntPair(const char *Buff, const char *End, uint64_t Pair[2]);
93
  };
94
} // end namespace llvm
95
96
#endif