Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / unittests / MC / SystemZ / SystemZAsmLexerTest.cpp
blob53cb265a4162c2dde132c9f5344dc8cd80160811
1 //===- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===--------------------------------------------------------------------===//
8 #include "llvm/MC/MCAsmInfo.h"
9 #include "llvm/MC/MCContext.h"
10 #include "llvm/MC/MCInstrInfo.h"
11 #include "llvm/MC/MCObjectFileInfo.h"
12 #include "llvm/MC/MCParser/MCAsmLexer.h"
13 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
14 #include "llvm/MC/MCRegisterInfo.h"
15 #include "llvm/MC/MCStreamer.h"
16 #include "llvm/MC/MCSubtargetInfo.h"
17 #include "llvm/MC/MCSymbol.h"
18 #include "llvm/MC/TargetRegistry.h"
19 #include "llvm/Support/MemoryBuffer.h"
20 #include "llvm/Support/SourceMgr.h"
21 #include "llvm/Support/TargetSelect.h"
23 #include "gtest/gtest.h"
25 using namespace llvm;
27 namespace {
29 // Setup a testing class that the GTest framework can call.
30 class SystemZAsmLexerTest : public ::testing::Test {
31 protected:
32 static void SetUpTestCase() {
33 LLVMInitializeSystemZTargetInfo();
34 LLVMInitializeSystemZTargetMC();
35 LLVMInitializeSystemZAsmParser();
38 std::unique_ptr<MCRegisterInfo> MRI;
39 std::unique_ptr<MCAsmInfo> MAI;
40 std::unique_ptr<const MCInstrInfo> MII;
41 std::unique_ptr<MCObjectFileInfo> MOFI;
42 std::unique_ptr<MCStreamer> Str;
43 std::unique_ptr<MCAsmParser> Parser;
44 std::unique_ptr<MCContext> Ctx;
45 std::unique_ptr<MCSubtargetInfo> STI;
46 std::unique_ptr<MCTargetAsmParser> TargetAsmParser;
48 SourceMgr SrcMgr;
49 std::string TripleName;
50 llvm::Triple Triple;
51 const Target *TheTarget;
53 const MCTargetOptions MCOptions;
55 SystemZAsmLexerTest() = delete;
57 SystemZAsmLexerTest(std::string SystemZTriple) {
58 // We will use the SystemZ triple, because of missing
59 // Object File and Streamer support for the z/OS target.
60 TripleName = SystemZTriple;
61 Triple = llvm::Triple(TripleName);
63 std::string Error;
64 TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
65 EXPECT_NE(TheTarget, nullptr);
67 MRI.reset(TheTarget->createMCRegInfo(TripleName));
68 EXPECT_NE(MRI, nullptr);
70 MII.reset(TheTarget->createMCInstrInfo());
71 EXPECT_NE(MII, nullptr);
73 STI.reset(TheTarget->createMCSubtargetInfo(TripleName, "z10", ""));
74 EXPECT_NE(STI, nullptr);
76 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
77 EXPECT_NE(MAI, nullptr);
80 void setupCallToAsmParser(StringRef AsmStr) {
81 std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(AsmStr));
82 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
83 EXPECT_EQ(Buffer, nullptr);
85 Ctx.reset(new MCContext(Triple, MAI.get(), MRI.get(), STI.get(), &SrcMgr,
86 &MCOptions));
87 MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
88 /*LargeCodeModel=*/false));
89 Ctx->setObjectFileInfo(MOFI.get());
91 Str.reset(TheTarget->createNullStreamer(*Ctx));
93 Parser.reset(createMCAsmParser(SrcMgr, *Ctx, *Str, *MAI));
95 TargetAsmParser.reset(
96 TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
97 Parser->setTargetParser(*TargetAsmParser);
100 void lexAndCheckTokens(StringRef AsmStr,
101 SmallVector<AsmToken::TokenKind> ExpectedTokens) {
102 // Get reference to AsmLexer.
103 MCAsmLexer &Lexer = Parser->getLexer();
104 // Loop through all expected tokens checking one by one.
105 for (size_t I = 0; I < ExpectedTokens.size(); ++I) {
106 EXPECT_EQ(Lexer.getTok().getKind(), ExpectedTokens[I]);
107 Lexer.Lex();
111 void lexAndCheckIntegerTokensAndValues(StringRef AsmStr,
112 SmallVector<int64_t> ExpectedValues) {
113 // Get reference to AsmLexer.
114 MCAsmLexer &Lexer = Parser->getLexer();
115 // Loop through all expected tokens and expected values.
116 for (size_t I = 0; I < ExpectedValues.size(); ++I) {
117 // Skip any EndOfStatement tokens, we're not concerned with them.
118 if (Lexer.getTok().getKind() == AsmToken::EndOfStatement)
119 continue;
120 EXPECT_EQ(Lexer.getTok().getKind(), AsmToken::Integer);
121 EXPECT_EQ(Lexer.getTok().getIntVal(), ExpectedValues[I]);
122 Lexer.Lex();
127 class SystemZAsmLexerLinux : public SystemZAsmLexerTest {
128 protected:
129 SystemZAsmLexerLinux() : SystemZAsmLexerTest("s390x-ibm-linux") {}
132 class SystemZAsmLexerZOS : public SystemZAsmLexerTest {
133 protected:
134 SystemZAsmLexerZOS() : SystemZAsmLexerTest("s390x-ibm-zos") {}
137 TEST_F(SystemZAsmLexerLinux, CheckDontRestrictCommentStringToStartOfStatement) {
138 StringRef AsmStr = "jne #-4";
140 // Setup.
141 setupCallToAsmParser(AsmStr);
143 // Lex initially to get the string.
144 Parser->getLexer().Lex();
146 SmallVector<AsmToken::TokenKind> ExpectedTokens(
147 {AsmToken::Identifier, AsmToken::EndOfStatement});
148 lexAndCheckTokens(AsmStr /* "jne #-4" */, ExpectedTokens);
151 TEST_F(SystemZAsmLexerZOS, CheckRestrictCommentStringToStartOfStatement) {
152 StringRef AsmStr = "jne #-4";
154 // Setup.
155 setupCallToAsmParser(AsmStr);
157 // Lex initially to get the string.
158 Parser->getLexer().Lex();
160 // When we are restricting the comment string to only the start of the
161 // statement, The sequence of tokens we are expecting are: Identifier - "jne"
162 // Hash - '#'
163 // Minus - '-'
164 // Integer - '4'
165 SmallVector<AsmToken::TokenKind> ExpectedTokens(
166 {AsmToken::Identifier, AsmToken::Space, AsmToken::Identifier});
167 lexAndCheckTokens(AsmStr /* "jne #-4" */, ExpectedTokens);
170 // Test HLASM Comment Syntax ('*')
171 TEST_F(SystemZAsmLexerZOS, CheckHLASMComment) {
172 StringRef AsmStr = "* lhi 1,10";
174 // Setup.
175 setupCallToAsmParser(AsmStr);
177 // Lex initially to get the string.
178 Parser->getLexer().Lex();
180 SmallVector<AsmToken::TokenKind> ExpectedTokens(
181 {AsmToken::EndOfStatement, AsmToken::Eof});
182 lexAndCheckTokens(AsmStr /* "* lhi 1,10" */, ExpectedTokens);
185 TEST_F(SystemZAsmLexerLinux, CheckHashDefault) {
186 StringRef AsmStr = "lh#123";
188 // Setup.
189 setupCallToAsmParser(AsmStr);
191 // Lex initially to get the string.
192 Parser->getLexer().Lex();
194 // "lh" -> Identifier
195 // "#123" -> EndOfStatement (Lexed as a comment since CommentString is "#")
196 SmallVector<AsmToken::TokenKind> ExpectedTokens(
197 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
198 lexAndCheckTokens(AsmStr, ExpectedTokens);
201 // Test if "#" is accepted as an Identifier
202 TEST_F(SystemZAsmLexerZOS, CheckAllowHashInIdentifier) {
203 StringRef AsmStr = "lh#123";
205 // Setup.
206 setupCallToAsmParser(AsmStr);
208 // Lex initially to get the string.
209 Parser->getLexer().Lex();
211 // "lh123" -> Identifier
212 SmallVector<AsmToken::TokenKind> ExpectedTokens(
213 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
214 lexAndCheckTokens(AsmStr, ExpectedTokens);
217 TEST_F(SystemZAsmLexerZOS, CheckAllowHashInIdentifier2) {
218 StringRef AsmStr = "lh#12*3";
220 // Setup.
221 setupCallToAsmParser(AsmStr);
223 // Lex initially to get the string.
224 Parser->getLexer().Lex();
226 // "lh#12" -> Identifier
227 // "*" -> Star
228 // "3" -> Integer
229 SmallVector<AsmToken::TokenKind> ExpectedTokens(
230 {AsmToken::Identifier, AsmToken::Star, AsmToken::Integer,
231 AsmToken::EndOfStatement, AsmToken::Eof});
232 lexAndCheckTokens(AsmStr, ExpectedTokens);
235 TEST_F(SystemZAsmLexerLinux, DontCheckStrictCommentString) {
236 StringRef AsmStr = "# abc\n/* def */// xyz";
238 // Setup.
239 setupCallToAsmParser(AsmStr);
241 // Lex initially to get the string.
242 Parser->getLexer().Lex();
244 SmallVector<AsmToken::TokenKind> ExpectedTokens(
245 {AsmToken::EndOfStatement, AsmToken::Comment, AsmToken::EndOfStatement,
246 AsmToken::Eof});
247 lexAndCheckTokens(AsmStr, ExpectedTokens);
250 TEST_F(SystemZAsmLexerZOS, CheckStrictCommentString) {
251 StringRef AsmStr = "# abc\n/* def */// xyz";
253 // Setup.
254 setupCallToAsmParser(AsmStr);
256 // Lex initially to get the string.
257 Parser->getLexer().Lex();
259 SmallVector<AsmToken::TokenKind> ExpectedTokens;
260 ExpectedTokens.push_back(AsmToken::Identifier); // "#"
261 ExpectedTokens.push_back(AsmToken::Space); // " "
262 ExpectedTokens.push_back(AsmToken::Identifier); // "abc"
263 ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
264 ExpectedTokens.push_back(AsmToken::Slash); // "/"
265 ExpectedTokens.push_back(AsmToken::Star); // "*"
266 ExpectedTokens.push_back(AsmToken::Space); // " "
267 ExpectedTokens.push_back(AsmToken::Identifier); // "def"
268 ExpectedTokens.push_back(AsmToken::Space); // " "
269 ExpectedTokens.push_back(AsmToken::Star); // "*"
270 ExpectedTokens.push_back(AsmToken::Slash); // "/"
271 ExpectedTokens.push_back(AsmToken::Slash); // "/"
272 ExpectedTokens.push_back(AsmToken::Slash); // "/"
273 ExpectedTokens.push_back(AsmToken::Space); // " "
274 ExpectedTokens.push_back(AsmToken::Identifier); // "xyz"
275 ExpectedTokens.push_back(AsmToken::EndOfStatement);
276 ExpectedTokens.push_back(AsmToken::Eof);
278 lexAndCheckTokens(AsmStr, ExpectedTokens);
281 TEST_F(SystemZAsmLexerZOS, CheckValidHLASMIntegers) {
282 StringRef AsmStr = "123\n000123\n1999\n007\n12300\n12021\n";
283 // StringRef AsmStr = "123";
284 // Setup.
285 setupCallToAsmParser(AsmStr);
287 // Lex initially to get the string.
288 Parser->getLexer().Lex();
290 // SmallVector<int64_t> ExpectedValues({123});
291 SmallVector<int64_t> ExpectedValues({123, 123, 1999, 7, 12300, 12021});
292 lexAndCheckIntegerTokensAndValues(AsmStr, ExpectedValues);
295 TEST_F(SystemZAsmLexerZOS, CheckInvalidHLASMIntegers) {
296 StringRef AsmStr = "0b0101\n0xDEADBEEF\nfffh\n.133\n";
298 // Setup.
299 setupCallToAsmParser(AsmStr);
301 // Lex initially to get the string.
302 Parser->getLexer().Lex();
304 SmallVector<AsmToken::TokenKind> ExpectedTokens;
305 ExpectedTokens.push_back(AsmToken::Integer); // "0"
306 ExpectedTokens.push_back(AsmToken::Identifier); // "b0101"
307 ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
308 ExpectedTokens.push_back(AsmToken::Integer); // "0"
309 ExpectedTokens.push_back(AsmToken::Identifier); // "xDEADBEEF"
310 ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
311 ExpectedTokens.push_back(AsmToken::Identifier); // "fffh"
312 ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
313 ExpectedTokens.push_back(AsmToken::Real); // ".133"
314 ExpectedTokens.push_back(AsmToken::EndOfStatement); // "\n"
315 ExpectedTokens.push_back(AsmToken::Eof);
316 lexAndCheckTokens(AsmStr, ExpectedTokens);
319 TEST_F(SystemZAsmLexerLinux, CheckDefaultIntegers) {
320 StringRef AsmStr = "0b0101\n0xDEADBEEF\nfffh\n";
322 // Setup.
323 setupCallToAsmParser(AsmStr);
325 // Lex initially to get the string.
326 Parser->getLexer().Lex();
328 SmallVector<int64_t> ExpectedValues({5, 0xDEADBEEF, 0xFFF});
329 lexAndCheckIntegerTokensAndValues(AsmStr, ExpectedValues);
332 TEST_F(SystemZAsmLexerLinux, CheckDefaultFloats) {
333 StringRef AsmStr = "0.333\n1.3\n2.5\n3.0\n";
335 // Setup.
336 setupCallToAsmParser(AsmStr);
338 // Lex initially to get the string.
339 Parser->getLexer().Lex();
341 SmallVector<AsmToken::TokenKind> ExpectedTokens;
343 for (int I = 0; I < 4; ++I)
344 ExpectedTokens.insert(ExpectedTokens.begin(),
345 {AsmToken::Real, AsmToken::EndOfStatement});
347 ExpectedTokens.push_back(AsmToken::Eof);
348 lexAndCheckTokens(AsmStr, ExpectedTokens);
351 TEST_F(SystemZAsmLexerLinux, CheckDefaultQuestionAtStartOfIdentifier) {
352 StringRef AsmStr = "?lh1?23";
354 // Setup.
355 setupCallToAsmParser(AsmStr);
357 // Lex initially to get the string.
358 Parser->getLexer().Lex();
360 SmallVector<AsmToken::TokenKind> ExpectedTokens(
361 {AsmToken::Question, AsmToken::Identifier, AsmToken::EndOfStatement,
362 AsmToken::Eof});
363 lexAndCheckTokens(AsmStr, ExpectedTokens);
366 TEST_F(SystemZAsmLexerLinux, CheckDefaultAtAtStartOfIdentifier) {
367 StringRef AsmStr = "@@lh1?23";
369 // Setup.
370 setupCallToAsmParser(AsmStr);
372 // Lex initially to get the string.
373 Parser->getLexer().Lex();
375 SmallVector<AsmToken::TokenKind> ExpectedTokens(
376 {AsmToken::At, AsmToken::At, AsmToken::Identifier,
377 AsmToken::EndOfStatement, AsmToken::Eof});
378 lexAndCheckTokens(AsmStr, ExpectedTokens);
381 TEST_F(SystemZAsmLexerZOS, CheckAcceptAtAtStartOfIdentifier) {
382 StringRef AsmStr = "@@lh1?23";
384 // Setup.
385 setupCallToAsmParser(AsmStr);
387 // Lex initially to get the string.
388 Parser->getLexer().Lex();
390 SmallVector<AsmToken::TokenKind> ExpectedTokens(
391 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
392 lexAndCheckTokens(AsmStr, ExpectedTokens);
395 TEST_F(SystemZAsmLexerLinux, CheckDefaultDollarAtStartOfIdentifier) {
396 StringRef AsmStr = "$$ac$c";
398 // Setup.
399 setupCallToAsmParser(AsmStr);
401 // Lex initially to get the string.
402 Parser->getLexer().Lex();
404 SmallVector<AsmToken::TokenKind> ExpectedTokens(
405 {AsmToken::Dollar, AsmToken::Dollar, AsmToken::Identifier,
406 AsmToken::EndOfStatement, AsmToken::Eof});
407 lexAndCheckTokens(AsmStr, ExpectedTokens);
410 TEST_F(SystemZAsmLexerZOS, CheckAcceptDollarAtStartOfIdentifier) {
411 StringRef AsmStr = "$$ab$c";
413 // Setup.
414 setupCallToAsmParser(AsmStr);
416 // Lex initially to get the string.
417 Parser->getLexer().Lex();
419 SmallVector<AsmToken::TokenKind> ExpectedTokens(
420 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
421 lexAndCheckTokens(AsmStr, ExpectedTokens);
424 TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier) {
425 StringRef AsmStr = "##a#b$c";
427 // Setup.
428 setupCallToAsmParser(AsmStr);
430 // Lex initially to get the string.
431 Parser->getLexer().Lex();
433 SmallVector<AsmToken::TokenKind> ExpectedTokens(
434 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
435 lexAndCheckTokens(AsmStr, ExpectedTokens);
438 TEST_F(SystemZAsmLexerLinux, CheckAcceptHashAtStartOfIdentifier2) {
439 StringRef AsmStr = "##a#b$c";
441 // Setup.
442 setupCallToAsmParser(AsmStr);
444 // Lex initially to get the string.
445 Parser->getLexer().Lex();
447 // By default, the CommentString attribute is set to "#".
448 // Hence, "##a#b$c" is lexed as a line comment irrespective
449 // of whether the AllowHashAtStartOfIdentifier attribute is set to true.
450 SmallVector<AsmToken::TokenKind> ExpectedTokens(
451 {AsmToken::EndOfStatement, AsmToken::Eof});
452 lexAndCheckTokens(AsmStr, ExpectedTokens);
455 TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier3) {
456 StringRef AsmStr = "##a#b$c";
458 // Setup.
459 setupCallToAsmParser(AsmStr);
461 // Lex initially to get the string.
462 Parser->getLexer().Lex();
464 SmallVector<AsmToken::TokenKind> ExpectedTokens(
465 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
466 lexAndCheckTokens(AsmStr, ExpectedTokens);
469 TEST_F(SystemZAsmLexerZOS, CheckAcceptHashAtStartOfIdentifier4) {
470 StringRef AsmStr = "##a#b$c";
472 // Setup.
473 setupCallToAsmParser(AsmStr);
475 // Lex initially to get the string.
476 Parser->getLexer().Lex();
478 // Since, the AllowAdditionalComments attribute is set to false,
479 // only strings starting with the CommentString attribute are
480 // lexed as possible comments.
481 // Hence, "##a$b$c" is lexed as an Identifier because the
482 // AllowHashAtStartOfIdentifier attribute is set to true.
483 SmallVector<AsmToken::TokenKind> ExpectedTokens(
484 {AsmToken::Identifier, AsmToken::EndOfStatement, AsmToken::Eof});
485 lexAndCheckTokens(AsmStr, ExpectedTokens);
488 TEST_F(SystemZAsmLexerZOS, CheckRejectDotAsCurrentPC) {
489 StringRef AsmStr = ".-4";
491 // Setup.
492 setupCallToAsmParser(AsmStr);
494 // Lex initially to get the string.
495 Parser->getLexer().Lex();
497 const MCExpr *Expr;
498 bool ParsePrimaryExpr = Parser->parseExpression(Expr);
499 EXPECT_EQ(ParsePrimaryExpr, true);
500 EXPECT_EQ(Parser->hasPendingError(), true);
503 TEST_F(SystemZAsmLexerLinux, CheckRejectStarAsCurrentPC) {
504 StringRef AsmStr = "*-4";
506 // Setup.
507 setupCallToAsmParser(AsmStr);
509 // Lex initially to get the string.
510 Parser->getLexer().Lex();
512 const MCExpr *Expr;
513 bool ParsePrimaryExpr = Parser->parseExpression(Expr);
514 EXPECT_EQ(ParsePrimaryExpr, true);
515 EXPECT_EQ(Parser->hasPendingError(), true);
518 TEST_F(SystemZAsmLexerZOS, CheckRejectCharLiterals) {
519 StringRef AsmStr = "abc 'd'";
521 // Setup.
522 setupCallToAsmParser(AsmStr);
524 // Lex initially to get the string.
525 Parser->getLexer().Lex();
527 SmallVector<AsmToken::TokenKind> ExpectedTokens(
528 {AsmToken::Identifier, AsmToken::Space, AsmToken::Error, AsmToken::Error,
529 AsmToken::EndOfStatement, AsmToken::Eof});
530 lexAndCheckTokens(AsmStr, ExpectedTokens);
533 TEST_F(SystemZAsmLexerZOS, CheckRejectStringLiterals) {
534 StringRef AsmStr = "abc \"ef\"";
536 // Setup.
537 setupCallToAsmParser(AsmStr);
539 // Lex initially to get the string.
540 Parser->getLexer().Lex();
542 SmallVector<AsmToken::TokenKind> ExpectedTokens(
543 {AsmToken::Identifier, AsmToken::Space, AsmToken::Error,
544 AsmToken::Identifier, AsmToken::Error, AsmToken::EndOfStatement,
545 AsmToken::Eof});
546 lexAndCheckTokens(AsmStr, ExpectedTokens);
549 TEST_F(SystemZAsmLexerZOS, CheckPrintAcceptableSymbol) {
550 std::string AsmStr = "ab13_$.@";
551 EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
552 AsmStr += "#";
553 EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
556 TEST_F(SystemZAsmLexerLinux, CheckPrintAcceptableSymbol) {
557 std::string AsmStr = "ab13_$.";
558 EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
559 AsmStr = "ab13_$.@";
560 EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
561 AsmStr = "ab13_$.#";
562 EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
565 TEST_F(SystemZAsmLexerZOS, CheckLabelCaseUpperCase) {
566 StringRef AsmStr = "label";
568 // Setup.
569 setupCallToAsmParser(AsmStr);
571 // Lex initially to get the string.
572 Parser->getLexer().Lex();
574 const MCExpr *Expr;
575 bool ParsePrimaryExpr = Parser->parseExpression(Expr);
576 EXPECT_EQ(ParsePrimaryExpr, false);
578 const MCSymbolRefExpr *SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
579 EXPECT_NE(SymbolExpr, nullptr);
580 EXPECT_NE(&SymbolExpr->getSymbol(), nullptr);
581 EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("LABEL"));
584 TEST_F(SystemZAsmLexerLinux, CheckLabelUpperCase2) {
585 StringRef AsmStr = "label";
587 // Setup.
588 setupCallToAsmParser(AsmStr);
590 // Lex initially to get the string.
591 Parser->getLexer().Lex();
593 const MCExpr *Expr;
594 bool ParsePrimaryExpr = Parser->parseExpression(Expr);
595 EXPECT_EQ(ParsePrimaryExpr, false);
597 const MCSymbolRefExpr *SymbolExpr = dyn_cast<MCSymbolRefExpr>(Expr);
598 EXPECT_NE(SymbolExpr, nullptr);
599 EXPECT_NE(&SymbolExpr->getSymbol(), nullptr);
600 EXPECT_EQ((&SymbolExpr->getSymbol())->getName(), StringRef("label"));
602 } // end anonymous namespace