xref: /llvm-project/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp (revision 682fe17e08c52bbdd2c2894ed08a3f9445660cbe)
1301d9261SAnirudh Prasad //===- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp ----------------===//
2301d9261SAnirudh Prasad //
3301d9261SAnirudh Prasad // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4301d9261SAnirudh Prasad // See https://llvm.org/LICENSE.txt for license information.
5301d9261SAnirudh Prasad // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6301d9261SAnirudh Prasad //
7301d9261SAnirudh Prasad //===--------------------------------------------------------------------===//
8301d9261SAnirudh Prasad #include "llvm/MC/MCAsmInfo.h"
9301d9261SAnirudh Prasad #include "llvm/MC/MCContext.h"
1006943537Sserge-sans-paille #include "llvm/MC/MCInstrInfo.h"
11301d9261SAnirudh Prasad #include "llvm/MC/MCObjectFileInfo.h"
1206943537Sserge-sans-paille #include "llvm/MC/MCParser/MCAsmLexer.h"
13301d9261SAnirudh Prasad #include "llvm/MC/MCParser/MCTargetAsmParser.h"
14301d9261SAnirudh Prasad #include "llvm/MC/MCRegisterInfo.h"
15301d9261SAnirudh Prasad #include "llvm/MC/MCStreamer.h"
16ef736a1cSserge-sans-paille #include "llvm/MC/MCSubtargetInfo.h"
17ef736a1cSserge-sans-paille #include "llvm/MC/MCSymbol.h"
1889b57061SReid Kleckner #include "llvm/MC/TargetRegistry.h"
19301d9261SAnirudh Prasad #include "llvm/Support/MemoryBuffer.h"
20301d9261SAnirudh Prasad #include "llvm/Support/SourceMgr.h"
21301d9261SAnirudh Prasad #include "llvm/Support/TargetSelect.h"
22301d9261SAnirudh Prasad 
23301d9261SAnirudh Prasad #include "gtest/gtest.h"
24301d9261SAnirudh Prasad 
25301d9261SAnirudh Prasad using namespace llvm;
26301d9261SAnirudh Prasad 
27301d9261SAnirudh Prasad namespace {
28301d9261SAnirudh Prasad 
29301d9261SAnirudh Prasad // Setup a testing class that the GTest framework can call.
30301d9261SAnirudh Prasad class SystemZAsmLexerTest : public ::testing::Test {
31301d9261SAnirudh Prasad protected:
SetUpTestCase()32301d9261SAnirudh Prasad   static void SetUpTestCase() {
33301d9261SAnirudh Prasad     LLVMInitializeSystemZTargetInfo();
34301d9261SAnirudh Prasad     LLVMInitializeSystemZTargetMC();
35ded0a70aSAnirudh Prasad     LLVMInitializeSystemZAsmParser();
36301d9261SAnirudh Prasad   }
37301d9261SAnirudh Prasad 
38301d9261SAnirudh Prasad   std::unique_ptr<MCRegisterInfo> MRI;
39fb99424aSAnirudh Prasad   std::unique_ptr<MCAsmInfo> MAI;
40301d9261SAnirudh Prasad   std::unique_ptr<const MCInstrInfo> MII;
41c2f819afSPhilipp Krones   std::unique_ptr<MCObjectFileInfo> MOFI;
42301d9261SAnirudh Prasad   std::unique_ptr<MCStreamer> Str;
43301d9261SAnirudh Prasad   std::unique_ptr<MCAsmParser> Parser;
44301d9261SAnirudh Prasad   std::unique_ptr<MCContext> Ctx;
45ded0a70aSAnirudh Prasad   std::unique_ptr<MCSubtargetInfo> STI;
46ded0a70aSAnirudh Prasad   std::unique_ptr<MCTargetAsmParser> TargetAsmParser;
47301d9261SAnirudh Prasad 
48301d9261SAnirudh Prasad   SourceMgr SrcMgr;
49301d9261SAnirudh Prasad   std::string TripleName;
50301d9261SAnirudh Prasad   llvm::Triple Triple;
51301d9261SAnirudh Prasad   const Target *TheTarget;
52301d9261SAnirudh Prasad 
53301d9261SAnirudh Prasad   const MCTargetOptions MCOptions;
54301d9261SAnirudh Prasad 
55fb99424aSAnirudh Prasad   SystemZAsmLexerTest() = delete;
56fb99424aSAnirudh Prasad 
SystemZAsmLexerTest(std::string SystemZTriple)57fb99424aSAnirudh Prasad   SystemZAsmLexerTest(std::string SystemZTriple) {
58301d9261SAnirudh Prasad     // We will use the SystemZ triple, because of missing
59301d9261SAnirudh Prasad     // Object File and Streamer support for the z/OS target.
60fb99424aSAnirudh Prasad     TripleName = SystemZTriple;
61301d9261SAnirudh Prasad     Triple = llvm::Triple(TripleName);
62301d9261SAnirudh Prasad 
63301d9261SAnirudh Prasad     std::string Error;
64301d9261SAnirudh Prasad     TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
65301d9261SAnirudh Prasad     EXPECT_NE(TheTarget, nullptr);
66301d9261SAnirudh Prasad 
67301d9261SAnirudh Prasad     MRI.reset(TheTarget->createMCRegInfo(TripleName));
68301d9261SAnirudh Prasad     EXPECT_NE(MRI, nullptr);
69301d9261SAnirudh Prasad 
70ded0a70aSAnirudh Prasad     MII.reset(TheTarget->createMCInstrInfo());
71ded0a70aSAnirudh Prasad     EXPECT_NE(MII, nullptr);
72ded0a70aSAnirudh Prasad 
73ded0a70aSAnirudh Prasad     STI.reset(TheTarget->createMCSubtargetInfo(TripleName, "z10", ""));
74ded0a70aSAnirudh Prasad     EXPECT_NE(STI, nullptr);
75ded0a70aSAnirudh Prasad 
76301d9261SAnirudh Prasad     MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
77301d9261SAnirudh Prasad     EXPECT_NE(MAI, nullptr);
78301d9261SAnirudh Prasad   }
79301d9261SAnirudh Prasad 
setupCallToAsmParser(StringRef AsmStr)80301d9261SAnirudh Prasad   void setupCallToAsmParser(StringRef AsmStr) {
81301d9261SAnirudh Prasad     std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(AsmStr));
82301d9261SAnirudh Prasad     SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
83301d9261SAnirudh Prasad     EXPECT_EQ(Buffer, nullptr);
84301d9261SAnirudh Prasad 
85fb99424aSAnirudh Prasad     Ctx.reset(new MCContext(Triple, MAI.get(), MRI.get(), STI.get(), &SrcMgr,
86c2f819afSPhilipp Krones                             &MCOptions));
87c2f819afSPhilipp Krones     MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
88c2f819afSPhilipp Krones                                                  /*LargeCodeModel=*/false));
89c2f819afSPhilipp Krones     Ctx->setObjectFileInfo(MOFI.get());
90301d9261SAnirudh Prasad 
91301d9261SAnirudh Prasad     Str.reset(TheTarget->createNullStreamer(*Ctx));
92301d9261SAnirudh Prasad 
93fb99424aSAnirudh Prasad     Parser.reset(createMCAsmParser(SrcMgr, *Ctx, *Str, *MAI));
94ded0a70aSAnirudh Prasad 
95ded0a70aSAnirudh Prasad     TargetAsmParser.reset(
96ded0a70aSAnirudh Prasad         TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
97ded0a70aSAnirudh Prasad     Parser->setTargetParser(*TargetAsmParser);
98301d9261SAnirudh Prasad   }
99301d9261SAnirudh Prasad 
lexAndCheckTokens(StringRef AsmStr,SmallVector<AsmToken::TokenKind> ExpectedTokens)100301d9261SAnirudh Prasad   void lexAndCheckTokens(StringRef AsmStr,
101301d9261SAnirudh Prasad                          SmallVector<AsmToken::TokenKind> ExpectedTokens) {
102301d9261SAnirudh Prasad     // Get reference to AsmLexer.
103301d9261SAnirudh Prasad     MCAsmLexer &Lexer = Parser->getLexer();
104301d9261SAnirudh Prasad     // Loop through all expected tokens checking one by one.
105301d9261SAnirudh Prasad     for (size_t I = 0; I < ExpectedTokens.size(); ++I) {
106301d9261SAnirudh Prasad       EXPECT_EQ(Lexer.getTok().getKind(), ExpectedTokens[I]);
107301d9261SAnirudh Prasad       Lexer.Lex();
108301d9261SAnirudh Prasad     }
109301d9261SAnirudh Prasad   }
1106ddd8c28SAnirudh Prasad 
lexAndCheckIntegerTokensAndValues(StringRef AsmStr,SmallVector<int64_t> ExpectedValues)1116ddd8c28SAnirudh Prasad   void lexAndCheckIntegerTokensAndValues(StringRef AsmStr,
1126ddd8c28SAnirudh Prasad                                          SmallVector<int64_t> ExpectedValues) {
1136ddd8c28SAnirudh Prasad     // Get reference to AsmLexer.
1146ddd8c28SAnirudh Prasad     MCAsmLexer &Lexer = Parser->getLexer();
1156ddd8c28SAnirudh Prasad     // Loop through all expected tokens and expected values.
1166ddd8c28SAnirudh Prasad     for (size_t I = 0; I < ExpectedValues.size(); ++I) {
1176ddd8c28SAnirudh Prasad       // Skip any EndOfStatement tokens, we're not concerned with them.
1186ddd8c28SAnirudh Prasad       if (Lexer.getTok().getKind() == AsmToken::EndOfStatement)
1196ddd8c28SAnirudh Prasad         continue;
1206ddd8c28SAnirudh Prasad       EXPECT_EQ(Lexer.getTok().getKind(), AsmToken::Integer);
1216ddd8c28SAnirudh Prasad       EXPECT_EQ(Lexer.getTok().getIntVal(), ExpectedValues[I]);
1226ddd8c28SAnirudh Prasad       Lexer.Lex();
1236ddd8c28SAnirudh Prasad     }
1246ddd8c28SAnirudh Prasad   }
125301d9261SAnirudh Prasad };
126301d9261SAnirudh Prasad 
127fb99424aSAnirudh Prasad class SystemZAsmLexerLinux : public SystemZAsmLexerTest {
128fb99424aSAnirudh Prasad protected:
SystemZAsmLexerLinux()129fb99424aSAnirudh Prasad   SystemZAsmLexerLinux() : SystemZAsmLexerTest("s390x-ibm-linux") {}
130fb99424aSAnirudh Prasad };
131fb99424aSAnirudh Prasad 
132fb99424aSAnirudh Prasad class SystemZAsmLexerZOS : public SystemZAsmLexerTest {
133fb99424aSAnirudh Prasad protected:
SystemZAsmLexerZOS()134fb99424aSAnirudh Prasad   SystemZAsmLexerZOS() : SystemZAsmLexerTest("s390x-ibm-zos") {}
135fb99424aSAnirudh Prasad };
136fb99424aSAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckDontRestrictCommentStringToStartOfStatement)137fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckDontRestrictCommentStringToStartOfStatement) {
138301d9261SAnirudh Prasad   StringRef AsmStr = "jne #-4";
139301d9261SAnirudh Prasad 
140301d9261SAnirudh Prasad   // Setup.
141301d9261SAnirudh Prasad   setupCallToAsmParser(AsmStr);
142301d9261SAnirudh Prasad 
1437b921a67SAnirudh Prasad   // Lex initially to get the string.
1447b921a67SAnirudh Prasad   Parser->getLexer().Lex();
1457b921a67SAnirudh Prasad 
146301d9261SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
147301d9261SAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement});
148301d9261SAnirudh Prasad   lexAndCheckTokens(AsmStr /* "jne #-4" */, ExpectedTokens);
149301d9261SAnirudh Prasad }
150301d9261SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckRestrictCommentStringToStartOfStatement)151fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckRestrictCommentStringToStartOfStatement) {
152301d9261SAnirudh Prasad   StringRef AsmStr = "jne #-4";
153301d9261SAnirudh Prasad 
154301d9261SAnirudh Prasad   // Setup.
155301d9261SAnirudh Prasad   setupCallToAsmParser(AsmStr);
156301d9261SAnirudh Prasad 
1577b921a67SAnirudh Prasad   // Lex initially to get the string.
1587b921a67SAnirudh Prasad   Parser->getLexer().Lex();
1597b921a67SAnirudh Prasad 
160301d9261SAnirudh Prasad   // When we are restricting the comment string to only the start of the
161301d9261SAnirudh Prasad   // statement, The sequence of tokens we are expecting are: Identifier - "jne"
162301d9261SAnirudh Prasad   // Hash - '#'
163301d9261SAnirudh Prasad   // Minus - '-'
164301d9261SAnirudh Prasad   // Integer - '4'
165301d9261SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
166fb99424aSAnirudh Prasad       {AsmToken::Identifier, AsmToken::Space, AsmToken::Identifier});
167301d9261SAnirudh Prasad   lexAndCheckTokens(AsmStr /* "jne #-4" */, ExpectedTokens);
168301d9261SAnirudh Prasad }
169301d9261SAnirudh Prasad 
170301d9261SAnirudh Prasad // Test HLASM Comment Syntax ('*')
TEST_F(SystemZAsmLexerZOS,CheckHLASMComment)171fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckHLASMComment) {
172301d9261SAnirudh Prasad   StringRef AsmStr = "* lhi 1,10";
173301d9261SAnirudh Prasad 
174301d9261SAnirudh Prasad   // Setup.
175301d9261SAnirudh Prasad   setupCallToAsmParser(AsmStr);
176301d9261SAnirudh Prasad 
1777b921a67SAnirudh Prasad   // Lex initially to get the string.
1787b921a67SAnirudh Prasad   Parser->getLexer().Lex();
1797b921a67SAnirudh Prasad 
180301d9261SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
181301d9261SAnirudh Prasad       {AsmToken::EndOfStatement, AsmToken::Eof});
182301d9261SAnirudh Prasad   lexAndCheckTokens(AsmStr /* "* lhi 1,10" */, ExpectedTokens);
183301d9261SAnirudh Prasad }
1847b921a67SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckHashDefault)185fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckHashDefault) {
1867b921a67SAnirudh Prasad   StringRef AsmStr = "lh#123";
1877b921a67SAnirudh Prasad 
1887b921a67SAnirudh Prasad   // Setup.
1897b921a67SAnirudh Prasad   setupCallToAsmParser(AsmStr);
1907b921a67SAnirudh Prasad 
1917b921a67SAnirudh Prasad   // Lex initially to get the string.
1927b921a67SAnirudh Prasad   Parser->getLexer().Lex();
1937b921a67SAnirudh Prasad 
1947b921a67SAnirudh Prasad   // "lh" -> Identifier
1957b921a67SAnirudh Prasad   // "#123" -> EndOfStatement (Lexed as a comment since CommentString is "#")
1967b921a67SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
1977b921a67SAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
1987b921a67SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
1997b921a67SAnirudh Prasad }
2007b921a67SAnirudh Prasad 
2017b921a67SAnirudh Prasad // Test if "#" is accepted as an Identifier
TEST_F(SystemZAsmLexerZOS,CheckAllowHashInIdentifier)202fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAllowHashInIdentifier) {
2037b921a67SAnirudh Prasad   StringRef AsmStr = "lh#123";
2047b921a67SAnirudh Prasad 
2057b921a67SAnirudh Prasad   // Setup.
2067b921a67SAnirudh Prasad   setupCallToAsmParser(AsmStr);
2077b921a67SAnirudh Prasad 
2087b921a67SAnirudh Prasad   // Lex initially to get the string.
2097b921a67SAnirudh Prasad   Parser->getLexer().Lex();
2107b921a67SAnirudh Prasad 
2117b921a67SAnirudh Prasad   // "lh123" -> Identifier
2127b921a67SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
2137b921a67SAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
2147b921a67SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
2157b921a67SAnirudh Prasad }
2167b921a67SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckAllowHashInIdentifier2)217fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAllowHashInIdentifier2) {
2187b921a67SAnirudh Prasad   StringRef AsmStr = "lh#12*3";
2197b921a67SAnirudh Prasad 
2207b921a67SAnirudh Prasad   // Setup.
2217b921a67SAnirudh Prasad   setupCallToAsmParser(AsmStr);
2227b921a67SAnirudh Prasad 
2237b921a67SAnirudh Prasad   // Lex initially to get the string.
2247b921a67SAnirudh Prasad   Parser->getLexer().Lex();
2257b921a67SAnirudh Prasad 
2267b921a67SAnirudh Prasad   // "lh#12" -> Identifier
2277b921a67SAnirudh Prasad   // "*" -> Star
2287b921a67SAnirudh Prasad   // "3" -> Integer
2297b921a67SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
2307b921a67SAnirudh Prasad       {AsmToken::Identifier, AsmToken::Star, AsmToken::Integer,
2317b921a67SAnirudh Prasad        AsmToken::EndOfStatement, AsmToken::Eof});
2327b921a67SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
2337b921a67SAnirudh Prasad }
234f7eec839SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,DontCheckStrictCommentString)235fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, DontCheckStrictCommentString) {
236f7eec839SAnirudh Prasad   StringRef AsmStr = "# abc\n/* def *///  xyz";
237f7eec839SAnirudh Prasad 
238f7eec839SAnirudh Prasad   // Setup.
239f7eec839SAnirudh Prasad   setupCallToAsmParser(AsmStr);
240f7eec839SAnirudh Prasad 
241f7eec839SAnirudh Prasad   // Lex initially to get the string.
242f7eec839SAnirudh Prasad   Parser->getLexer().Lex();
243f7eec839SAnirudh Prasad 
244f7eec839SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
245f7eec839SAnirudh Prasad       {AsmToken::EndOfStatement, AsmToken::Comment, AsmToken::EndOfStatement,
246f7eec839SAnirudh Prasad        AsmToken::Eof});
247f7eec839SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
248f7eec839SAnirudh Prasad }
249f7eec839SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckStrictCommentString)250fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckStrictCommentString) {
251f7eec839SAnirudh Prasad   StringRef AsmStr = "# abc\n/* def *///  xyz";
252f7eec839SAnirudh Prasad 
253f7eec839SAnirudh Prasad   // Setup.
254f7eec839SAnirudh Prasad   setupCallToAsmParser(AsmStr);
255f7eec839SAnirudh Prasad 
256f7eec839SAnirudh Prasad   // Lex initially to get the string.
257f7eec839SAnirudh Prasad   Parser->getLexer().Lex();
258f7eec839SAnirudh Prasad 
259f7eec839SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens;
260fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "#"
261fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Space);          // " "
262fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "abc"
263fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
264f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Slash);          // "/"
265f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Star);           // "*"
266fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Space);          // " "
267f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "def"
268fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Space);          // " "
269f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Star);           // "*"
270f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Slash);          // "/"
271f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Slash);          // "/"
272f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Slash);          // "/"
273fb99424aSAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Space);          // " "
274f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "xyz"
275f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::EndOfStatement);
276f7eec839SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Eof);
277f7eec839SAnirudh Prasad 
278f7eec839SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
279f7eec839SAnirudh Prasad }
280f7eec839SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckValidHLASMIntegers)281fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckValidHLASMIntegers) {
2826ddd8c28SAnirudh Prasad   StringRef AsmStr = "123\n000123\n1999\n007\n12300\n12021\n";
2836ddd8c28SAnirudh Prasad   // StringRef AsmStr = "123";
2846ddd8c28SAnirudh Prasad   // Setup.
2856ddd8c28SAnirudh Prasad   setupCallToAsmParser(AsmStr);
2866ddd8c28SAnirudh Prasad 
2876ddd8c28SAnirudh Prasad   // Lex initially to get the string.
2886ddd8c28SAnirudh Prasad   Parser->getLexer().Lex();
2896ddd8c28SAnirudh Prasad 
2906ddd8c28SAnirudh Prasad   // SmallVector<int64_t> ExpectedValues({123});
2916ddd8c28SAnirudh Prasad   SmallVector<int64_t> ExpectedValues({123, 123, 1999, 7, 12300, 12021});
2926ddd8c28SAnirudh Prasad   lexAndCheckIntegerTokensAndValues(AsmStr, ExpectedValues);
2936ddd8c28SAnirudh Prasad }
2946ddd8c28SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckInvalidHLASMIntegers)295fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckInvalidHLASMIntegers) {
2966ddd8c28SAnirudh Prasad   StringRef AsmStr = "0b0101\n0xDEADBEEF\nfffh\n.133\n";
2976ddd8c28SAnirudh Prasad 
2986ddd8c28SAnirudh Prasad   // Setup.
2996ddd8c28SAnirudh Prasad   setupCallToAsmParser(AsmStr);
3006ddd8c28SAnirudh Prasad 
3016ddd8c28SAnirudh Prasad   // Lex initially to get the string.
3026ddd8c28SAnirudh Prasad   Parser->getLexer().Lex();
3036ddd8c28SAnirudh Prasad 
3046ddd8c28SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens;
3056ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Integer);        // "0"
3066ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "b0101"
3076ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
3086ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Integer);        // "0"
3096ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "xDEADBEEF"
3106ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
3116ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Identifier);     // "fffh"
3126ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
3136ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Real);           // ".133"
3146ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
3156ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Eof);
3166ddd8c28SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
3176ddd8c28SAnirudh Prasad }
3186ddd8c28SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckDefaultIntegers)319fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckDefaultIntegers) {
3206ddd8c28SAnirudh Prasad   StringRef AsmStr = "0b0101\n0xDEADBEEF\nfffh\n";
3216ddd8c28SAnirudh Prasad 
3226ddd8c28SAnirudh Prasad   // Setup.
3236ddd8c28SAnirudh Prasad   setupCallToAsmParser(AsmStr);
3246ddd8c28SAnirudh Prasad 
3256ddd8c28SAnirudh Prasad   // Lex initially to get the string.
3266ddd8c28SAnirudh Prasad   Parser->getLexer().Lex();
3276ddd8c28SAnirudh Prasad 
3286ddd8c28SAnirudh Prasad   SmallVector<int64_t> ExpectedValues({5, 0xDEADBEEF, 0xFFF});
3296ddd8c28SAnirudh Prasad   lexAndCheckIntegerTokensAndValues(AsmStr, ExpectedValues);
3306ddd8c28SAnirudh Prasad }
3316ddd8c28SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckDefaultFloats)332fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckDefaultFloats) {
3336ddd8c28SAnirudh Prasad   StringRef AsmStr = "0.333\n1.3\n2.5\n3.0\n";
3346ddd8c28SAnirudh Prasad 
3356ddd8c28SAnirudh Prasad   // Setup.
3366ddd8c28SAnirudh Prasad   setupCallToAsmParser(AsmStr);
3376ddd8c28SAnirudh Prasad 
3386ddd8c28SAnirudh Prasad   // Lex initially to get the string.
3396ddd8c28SAnirudh Prasad   Parser->getLexer().Lex();
3406ddd8c28SAnirudh Prasad 
3416ddd8c28SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens;
3426ddd8c28SAnirudh Prasad 
3436ddd8c28SAnirudh Prasad   for (int I = 0; I < 4; ++I)
3446ddd8c28SAnirudh Prasad     ExpectedTokens.insert(ExpectedTokens.begin(),
3456ddd8c28SAnirudh Prasad                           {AsmToken::Real, AsmToken::EndOfStatement});
3466ddd8c28SAnirudh Prasad 
3476ddd8c28SAnirudh Prasad   ExpectedTokens.push_back(AsmToken::Eof);
3486ddd8c28SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
3496ddd8c28SAnirudh Prasad }
3508f6185c7SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckDefaultQuestionAtStartOfIdentifier)351fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckDefaultQuestionAtStartOfIdentifier) {
3528f6185c7SAnirudh Prasad   StringRef AsmStr = "?lh1?23";
3538f6185c7SAnirudh Prasad 
3548f6185c7SAnirudh Prasad   // Setup.
3558f6185c7SAnirudh Prasad   setupCallToAsmParser(AsmStr);
3568f6185c7SAnirudh Prasad 
3578f6185c7SAnirudh Prasad   // Lex initially to get the string.
3588f6185c7SAnirudh Prasad   Parser->getLexer().Lex();
3598f6185c7SAnirudh Prasad 
3608f6185c7SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
361*682fe17eSSergei Barannikov       {AsmToken::Question, AsmToken::Identifier, AsmToken::EndOfStatement,
3628f6185c7SAnirudh Prasad        AsmToken::Eof});
3638f6185c7SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
3648f6185c7SAnirudh Prasad }
3658f6185c7SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckDefaultAtAtStartOfIdentifier)366fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckDefaultAtAtStartOfIdentifier) {
3678f6185c7SAnirudh Prasad   StringRef AsmStr = "@@lh1?23";
3688f6185c7SAnirudh Prasad 
3698f6185c7SAnirudh Prasad   // Setup.
3708f6185c7SAnirudh Prasad   setupCallToAsmParser(AsmStr);
3718f6185c7SAnirudh Prasad 
3728f6185c7SAnirudh Prasad   // Lex initially to get the string.
3738f6185c7SAnirudh Prasad   Parser->getLexer().Lex();
3748f6185c7SAnirudh Prasad 
3758f6185c7SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
3768f6185c7SAnirudh Prasad       {AsmToken::At, AsmToken::At, AsmToken::Identifier,
3778f6185c7SAnirudh Prasad        AsmToken::EndOfStatement, AsmToken::Eof});
3788f6185c7SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
3798f6185c7SAnirudh Prasad }
3808f6185c7SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckAcceptAtAtStartOfIdentifier)381fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAcceptAtAtStartOfIdentifier) {
3828f6185c7SAnirudh Prasad   StringRef AsmStr = "@@lh1?23";
3838f6185c7SAnirudh Prasad 
3848f6185c7SAnirudh Prasad   // Setup.
3858f6185c7SAnirudh Prasad   setupCallToAsmParser(AsmStr);
3868f6185c7SAnirudh Prasad 
3878f6185c7SAnirudh Prasad   // Lex initially to get the string.
3888f6185c7SAnirudh Prasad   Parser->getLexer().Lex();
3898f6185c7SAnirudh Prasad 
3908f6185c7SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
3918f6185c7SAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
3928f6185c7SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
3938f6185c7SAnirudh Prasad }
3948f6185c7SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckDefaultDollarAtStartOfIdentifier)395fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckDefaultDollarAtStartOfIdentifier) {
3968f6185c7SAnirudh Prasad   StringRef AsmStr = "$$ac$c";
3978f6185c7SAnirudh Prasad 
3988f6185c7SAnirudh Prasad   // Setup.
3998f6185c7SAnirudh Prasad   setupCallToAsmParser(AsmStr);
4008f6185c7SAnirudh Prasad 
4018f6185c7SAnirudh Prasad   // Lex initially to get the string.
4028f6185c7SAnirudh Prasad   Parser->getLexer().Lex();
4038f6185c7SAnirudh Prasad 
4048f6185c7SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
4058f6185c7SAnirudh Prasad       {AsmToken::Dollar, AsmToken::Dollar, AsmToken::Identifier,
4068f6185c7SAnirudh Prasad        AsmToken::EndOfStatement, AsmToken::Eof});
4078f6185c7SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
4088f6185c7SAnirudh Prasad }
4098f6185c7SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckAcceptDollarAtStartOfIdentifier)410fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAcceptDollarAtStartOfIdentifier) {
4118f6185c7SAnirudh Prasad   StringRef AsmStr = "$$ab$c";
4128f6185c7SAnirudh Prasad 
4138f6185c7SAnirudh Prasad   // Setup.
4148f6185c7SAnirudh Prasad   setupCallToAsmParser(AsmStr);
4158f6185c7SAnirudh Prasad 
4168f6185c7SAnirudh Prasad   // Lex initially to get the string.
4178f6185c7SAnirudh Prasad   Parser->getLexer().Lex();
4188f6185c7SAnirudh Prasad 
4198f6185c7SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
4208f6185c7SAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
4218f6185c7SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
4228f6185c7SAnirudh Prasad }
42307b0a72dSAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckAcceptHashAtStartOfIdentifier)424fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier) {
42507b0a72dSAnirudh Prasad   StringRef AsmStr = "##a#b$c";
42607b0a72dSAnirudh Prasad 
42707b0a72dSAnirudh Prasad   // Setup.
42807b0a72dSAnirudh Prasad   setupCallToAsmParser(AsmStr);
42907b0a72dSAnirudh Prasad 
43007b0a72dSAnirudh Prasad   // Lex initially to get the string.
43107b0a72dSAnirudh Prasad   Parser->getLexer().Lex();
43207b0a72dSAnirudh Prasad 
43307b0a72dSAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
43407b0a72dSAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
43507b0a72dSAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
43607b0a72dSAnirudh Prasad }
43707b0a72dSAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckAcceptHashAtStartOfIdentifier2)438fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckAcceptHashAtStartOfIdentifier2) {
43907b0a72dSAnirudh Prasad   StringRef AsmStr = "##a#b$c";
44007b0a72dSAnirudh Prasad 
44107b0a72dSAnirudh Prasad   // Setup.
44207b0a72dSAnirudh Prasad   setupCallToAsmParser(AsmStr);
44307b0a72dSAnirudh Prasad 
44407b0a72dSAnirudh Prasad   // Lex initially to get the string.
44507b0a72dSAnirudh Prasad   Parser->getLexer().Lex();
44607b0a72dSAnirudh Prasad 
44707b0a72dSAnirudh Prasad   // By default, the CommentString attribute is set to "#".
44807b0a72dSAnirudh Prasad   // Hence, "##a#b$c" is lexed as a line comment irrespective
44907b0a72dSAnirudh Prasad   // of whether the AllowHashAtStartOfIdentifier attribute is set to true.
45007b0a72dSAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
45107b0a72dSAnirudh Prasad       {AsmToken::EndOfStatement, AsmToken::Eof});
45207b0a72dSAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
45307b0a72dSAnirudh Prasad }
45407b0a72dSAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckAcceptHashAtStartOfIdentifier3)455fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier3) {
45607b0a72dSAnirudh Prasad   StringRef AsmStr = "##a#b$c";
45707b0a72dSAnirudh Prasad 
45807b0a72dSAnirudh Prasad   // Setup.
45907b0a72dSAnirudh Prasad   setupCallToAsmParser(AsmStr);
46007b0a72dSAnirudh Prasad 
46107b0a72dSAnirudh Prasad   // Lex initially to get the string.
46207b0a72dSAnirudh Prasad   Parser->getLexer().Lex();
46307b0a72dSAnirudh Prasad 
46407b0a72dSAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
465fb99424aSAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
46607b0a72dSAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
46707b0a72dSAnirudh Prasad }
46807b0a72dSAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckAcceptHashAtStartOfIdentifier4)469fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier4) {
47007b0a72dSAnirudh Prasad   StringRef AsmStr = "##a#b$c";
47107b0a72dSAnirudh Prasad 
47207b0a72dSAnirudh Prasad   // Setup.
47307b0a72dSAnirudh Prasad   setupCallToAsmParser(AsmStr);
47407b0a72dSAnirudh Prasad 
47507b0a72dSAnirudh Prasad   // Lex initially to get the string.
47607b0a72dSAnirudh Prasad   Parser->getLexer().Lex();
47707b0a72dSAnirudh Prasad 
47807b0a72dSAnirudh Prasad   // Since, the AllowAdditionalComments attribute is set to false,
47907b0a72dSAnirudh Prasad   // only strings starting with the CommentString attribute are
48007b0a72dSAnirudh Prasad   // lexed as possible comments.
48107b0a72dSAnirudh Prasad   // Hence, "##a$b$c" is lexed as an Identifier because the
48207b0a72dSAnirudh Prasad   // AllowHashAtStartOfIdentifier attribute is set to true.
48307b0a72dSAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
48407b0a72dSAnirudh Prasad       {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
48507b0a72dSAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
48607b0a72dSAnirudh Prasad }
487ded0a70aSAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckRejectDotAsCurrentPC)488fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckRejectDotAsCurrentPC) {
489ded0a70aSAnirudh Prasad   StringRef AsmStr = ".-4";
490ded0a70aSAnirudh Prasad 
491ded0a70aSAnirudh Prasad   // Setup.
492ded0a70aSAnirudh Prasad   setupCallToAsmParser(AsmStr);
493ded0a70aSAnirudh Prasad 
494ded0a70aSAnirudh Prasad   // Lex initially to get the string.
495ded0a70aSAnirudh Prasad   Parser->getLexer().Lex();
496ded0a70aSAnirudh Prasad 
497ded0a70aSAnirudh Prasad   const MCExpr *Expr;
498ded0a70aSAnirudh Prasad   bool ParsePrimaryExpr = Parser->parseExpression(Expr);
499ded0a70aSAnirudh Prasad   EXPECT_EQ(ParsePrimaryExpr, true);
500ded0a70aSAnirudh Prasad   EXPECT_EQ(Parser->hasPendingError(), true);
501ded0a70aSAnirudh Prasad }
502ca02fab7SAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckRejectStarAsCurrentPC)503fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckRejectStarAsCurrentPC) {
504ca02fab7SAnirudh Prasad   StringRef AsmStr = "*-4";
505ca02fab7SAnirudh Prasad 
506ca02fab7SAnirudh Prasad   // Setup.
507ca02fab7SAnirudh Prasad   setupCallToAsmParser(AsmStr);
508ca02fab7SAnirudh Prasad 
509ca02fab7SAnirudh Prasad   // Lex initially to get the string.
510ca02fab7SAnirudh Prasad   Parser->getLexer().Lex();
511ca02fab7SAnirudh Prasad 
512ca02fab7SAnirudh Prasad   const MCExpr *Expr;
513ca02fab7SAnirudh Prasad   bool ParsePrimaryExpr = Parser->parseExpression(Expr);
514ca02fab7SAnirudh Prasad   EXPECT_EQ(ParsePrimaryExpr, true);
515ca02fab7SAnirudh Prasad   EXPECT_EQ(Parser->hasPendingError(), true);
516ca02fab7SAnirudh Prasad }
517ae2aef13SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckRejectCharLiterals)518fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckRejectCharLiterals) {
519ae2aef13SAnirudh Prasad   StringRef AsmStr = "abc 'd'";
520ae2aef13SAnirudh Prasad 
521ae2aef13SAnirudh Prasad   // Setup.
522ae2aef13SAnirudh Prasad   setupCallToAsmParser(AsmStr);
523ae2aef13SAnirudh Prasad 
524ae2aef13SAnirudh Prasad   // Lex initially to get the string.
525ae2aef13SAnirudh Prasad   Parser->getLexer().Lex();
526ae2aef13SAnirudh Prasad 
527ae2aef13SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
528fb99424aSAnirudh Prasad       {AsmToken::Identifier, AsmToken::Space, AsmToken::Error, AsmToken::Error,
529ae2aef13SAnirudh Prasad        AsmToken::EndOfStatement, AsmToken::Eof});
530ae2aef13SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
531ae2aef13SAnirudh Prasad }
532ae2aef13SAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckRejectStringLiterals)533fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckRejectStringLiterals) {
534ae2aef13SAnirudh Prasad   StringRef AsmStr = "abc \"ef\"";
535ae2aef13SAnirudh Prasad 
536ae2aef13SAnirudh Prasad   // Setup.
537ae2aef13SAnirudh Prasad   setupCallToAsmParser(AsmStr);
538ae2aef13SAnirudh Prasad 
539ae2aef13SAnirudh Prasad   // Lex initially to get the string.
540ae2aef13SAnirudh Prasad   Parser->getLexer().Lex();
541ae2aef13SAnirudh Prasad 
542ae2aef13SAnirudh Prasad   SmallVector<AsmToken::TokenKind> ExpectedTokens(
543fb99424aSAnirudh Prasad       {AsmToken::Identifier, AsmToken::Space, AsmToken::Error,
544fb99424aSAnirudh Prasad        AsmToken::Identifier, AsmToken::Error, AsmToken::EndOfStatement,
545fb99424aSAnirudh Prasad        AsmToken::Eof});
546ae2aef13SAnirudh Prasad   lexAndCheckTokens(AsmStr, ExpectedTokens);
547ae2aef13SAnirudh Prasad }
548b37a2fcdSAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckPrintAcceptableSymbol)549fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckPrintAcceptableSymbol) {
550b37a2fcdSAnirudh Prasad   std::string AsmStr = "ab13_$.@";
551fb99424aSAnirudh Prasad   EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
552b37a2fcdSAnirudh Prasad   AsmStr += "#";
553fb99424aSAnirudh Prasad   EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
554b37a2fcdSAnirudh Prasad }
555b37a2fcdSAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckPrintAcceptableSymbol)556fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckPrintAcceptableSymbol) {
557a8ebd85eSEli Friedman   std::string AsmStr = "ab13_$.";
558fb99424aSAnirudh Prasad   EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
559a8ebd85eSEli Friedman   AsmStr = "ab13_$.@";
560a8ebd85eSEli Friedman   EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
561a8ebd85eSEli Friedman   AsmStr = "ab13_$.#";
562fb99424aSAnirudh Prasad   EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
563fb99424aSAnirudh Prasad }
564fb99424aSAnirudh Prasad 
TEST_F(SystemZAsmLexerZOS,CheckLabelCaseUpperCase)565fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerZOS, CheckLabelCaseUpperCase) {
566fb99424aSAnirudh Prasad   StringRef AsmStr = "label";
567fb99424aSAnirudh Prasad 
568fb99424aSAnirudh Prasad   // Setup.
569fb99424aSAnirudh Prasad   setupCallToAsmParser(AsmStr);
570fb99424aSAnirudh Prasad 
571fb99424aSAnirudh Prasad   // Lex initially to get the string.
572fb99424aSAnirudh Prasad   Parser->getLexer().Lex();
573fb99424aSAnirudh Prasad 
574fb99424aSAnirudh Prasad   const MCExpr *Expr;
575fb99424aSAnirudh Prasad   bool ParsePrimaryExpr = Parser->parseExpression(Expr);
576fb99424aSAnirudh Prasad   EXPECT_EQ(ParsePrimaryExpr, false);
577fb99424aSAnirudh Prasad 
578fb99424aSAnirudh Prasad   const MCSymbolRefExpr *SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
579fb99424aSAnirudh Prasad   EXPECT_NE(SymbolExpr, nullptr);
580fb99424aSAnirudh Prasad   EXPECT_NE(&SymbolExpr->getSymbol(), nullptr);
581fb99424aSAnirudh Prasad   EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("LABEL"));
582fb99424aSAnirudh Prasad }
583fb99424aSAnirudh Prasad 
TEST_F(SystemZAsmLexerLinux,CheckLabelUpperCase2)584fb99424aSAnirudh Prasad TEST_F(SystemZAsmLexerLinux, CheckLabelUpperCase2) {
585fb99424aSAnirudh Prasad   StringRef AsmStr = "label";
58663136266SAnirudh Prasad 
58763136266SAnirudh Prasad   // Setup.
58863136266SAnirudh Prasad   setupCallToAsmParser(AsmStr);
58963136266SAnirudh Prasad 
59063136266SAnirudh Prasad   // Lex initially to get the string.
59163136266SAnirudh Prasad   Parser->getLexer().Lex();
59263136266SAnirudh Prasad 
59363136266SAnirudh Prasad   const MCExpr *Expr;
59463136266SAnirudh Prasad   bool ParsePrimaryExpr = Parser->parseExpression(Expr);
59563136266SAnirudh Prasad   EXPECT_EQ(ParsePrimaryExpr, false);
59663136266SAnirudh Prasad 
59763136266SAnirudh Prasad   const MCSymbolRefExpr *SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
59863136266SAnirudh Prasad   EXPECT_NE(SymbolExpr, nullptr);
59963136266SAnirudh Prasad   EXPECT_NE(&SymbolExpr->getSymbol(), nullptr);
60063136266SAnirudh Prasad   EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("label"));
60163136266SAnirudh Prasad }
602301d9261SAnirudh Prasad } // end anonymous namespace
603