mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[SystemZ][z/OS] Validate symbol names for z/OS for printing without quotes
- Currently, before printing a label in MCSymbol.cpp (MCSymbol::print), the current code "validates" the label that is to be printed. - If it fails the validation step, then it prints the label within double quotes. - However, the validation is provided as a virtual function in MCAsmInfo.h (i.e. isAcceptableChar() function). So we can override this for the AD_HLASM dialect in SystemZMCAsmInfo.cpp. Reviewed By: uweigand Differential Revision: https://reviews.llvm.org/D103091
This commit is contained in:
parent
47e83818b4
commit
f106aa368d
@ -37,3 +37,10 @@ SystemZMCAsmInfo::SystemZMCAsmInfo(const Triple &TT) {
|
||||
SupportsDebugInformation = true;
|
||||
ExceptionsType = ExceptionHandling::DwarfCFI;
|
||||
}
|
||||
|
||||
bool SystemZMCAsmInfo::isAcceptableChar(char C) const {
|
||||
if (AssemblerDialect == AD_ATT)
|
||||
return MCAsmInfo::isAcceptableChar(C);
|
||||
|
||||
return MCAsmInfo::isAcceptableChar(C) || C == '#';
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ enum SystemZAsmDialect { AD_ATT = 0, AD_HLASM = 1 };
|
||||
class SystemZMCAsmInfo : public MCAsmInfoELF {
|
||||
public:
|
||||
explicit SystemZMCAsmInfo(const Triple &TT);
|
||||
bool isAcceptableChar(char C) const override;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
AllowHashAtStartOfIdentifier = Value;
|
||||
}
|
||||
void setAllowDotIsPC(bool Value) { DotIsPC = Value; }
|
||||
void setAssemblerDialect(unsigned Value) { AssemblerDialect = Value; }
|
||||
};
|
||||
|
||||
// Setup a testing class that the GTest framework can call.
|
||||
@ -734,4 +735,19 @@ TEST_F(SystemZAsmLexerTest, CheckRejectStringLiterals) {
|
||||
AsmToken::Error, AsmToken::EndOfStatement, AsmToken::Eof});
|
||||
lexAndCheckTokens(AsmStr, ExpectedTokens);
|
||||
}
|
||||
|
||||
TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol) {
|
||||
std::string AsmStr = "ab13_$.@";
|
||||
EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
|
||||
AsmStr += "#";
|
||||
EXPECT_EQ(false, MUPMAI->isValidUnquotedName(AsmStr));
|
||||
}
|
||||
|
||||
TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol2) {
|
||||
MUPMAI->setAssemblerDialect(1);
|
||||
std::string AsmStr = "ab13_$.@";
|
||||
EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
|
||||
AsmStr += "#";
|
||||
EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user