remove one form of EmitString, just use EmitBytes instead. We must

be careful to add a \0 at the end though, because EmitString didn't
do this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94277 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-23 03:11:46 +00:00
parent 4fe5d72765
commit 4cf202ba06
5 changed files with 27 additions and 46 deletions

View File

@ -265,12 +265,6 @@ namespace llvm {
///
void EmitInt64(uint64_t Value) const;
/// EmitString - Emit a string with quotes and a null terminator.
/// Special characters are emitted properly.
/// @verbatim (Eg. '\t') @endverbatim
void EmitString(const StringRef String) const;
void EmitString(const char *String, unsigned Size) const;
/// EmitFile - Emit a .file directive.
void EmitFile(unsigned Number, StringRef Name) const;

View File

@ -715,29 +715,6 @@ static void printStringChar(formatted_raw_ostream &O, unsigned char C) {
}
}
/// EmitString - Emit a string with quotes and a null terminator.
/// Special characters are emitted properly.
/// \literal (Eg. '\t') \endliteral
void AsmPrinter::EmitString(const StringRef String) const {
EmitString(String.data(), String.size());
}
void AsmPrinter::EmitString(const char *String, unsigned Size) const {
const char* AscizDirective = MAI->getAscizDirective();
if (AscizDirective)
O << AscizDirective;
else
O << MAI->getAsciiDirective();
O << '\"';
for (unsigned i = 0; i < Size; ++i)
printStringChar(O, String[i]);
if (AscizDirective)
O << '\"';
else
O << "\\0\"";
}
/// EmitFile - Emit a .file directive.
void AsmPrinter::EmitFile(unsigned Number, StringRef Name) const {
O << "\t.file\t" << Number << " \"";

View File

@ -242,7 +242,9 @@ void DIEInteger::print(raw_ostream &O) {
/// EmitValue - Emit string value.
///
void DIEString::EmitValue(DwarfPrinter *D, unsigned Form) const {
D->getAsm()->EmitString(Str);
D->getAsm()->OutStreamer.EmitBytes(Str, /*addrspace*/0);
// Emit nul terminator.
D->getAsm()->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0);
}
#ifndef NDEBUG

View File

@ -344,7 +344,7 @@ void DwarfDebug::addSInt(DIE *Die, unsigned Attribute,
/// addString - Add a string attribute data and value. DIEString only
/// keeps string reference.
void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form,
const StringRef String) {
StringRef String) {
DIEValue *Value = new DIEString(String);
DIEValues.push_back(Value);
Die->addValue(Attribute, Form, Value);
@ -2526,8 +2526,9 @@ void DwarfDebug::emitDebugLines() {
// Emit directories.
for (unsigned DI = 1, DE = getNumSourceDirectories()+1; DI != DE; ++DI) {
Asm->EmitString(getSourceDirectoryName(DI));
EOL("Directory");
const std::string &Dir = getSourceDirectoryName(DI);
if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("Directory");
Asm->OutStreamer.EmitBytes(StringRef(Dir.c_str(), Dir.size()+1), 0);
}
Asm->EmitInt8(0); EOL("End of directories");
@ -2536,8 +2537,10 @@ void DwarfDebug::emitDebugLines() {
for (unsigned SI = 1, SE = getNumSourceIds()+1; SI != SE; ++SI) {
// Remember source id starts at 1.
std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
Asm->EmitString(getSourceFileName(Id.second));
EOL("Source");
const std::string &FN = getSourceFileName(Id.second);
if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("Source");
Asm->OutStreamer.EmitBytes(StringRef(FN.c_str(), FN.size()+1), 0);
EmitULEB128(Id.first, "Directory #");
EmitULEB128(0, "Mod date");
EmitULEB128(0, "File size");
@ -2661,7 +2664,7 @@ void DwarfDebug::emitCommonDebugFrame() {
EOL("CIE Identifier Tag");
Asm->EmitInt8(dwarf::DW_CIE_VERSION);
EOL("CIE Version");
Asm->EmitString("");
Asm->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0); // nul terminator.
EOL("CIE Augmentation");
EmitULEB128(1, "CIE Code Alignment Factor");
EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
@ -2743,7 +2746,10 @@ void DwarfDebug::emitDebugPubNames() {
DIE * Entity = GI->second;
Asm->EmitInt32(Entity->getOffset()); EOL("DIE offset");
Asm->EmitString(Name, strlen(Name)); EOL("External Name");
if (Asm->VerboseAsm)
Asm->OutStreamer.AddComment("External Name");
Asm->OutStreamer.EmitBytes(StringRef(Name, strlen(Name)+1), 0);
}
Asm->EmitInt32(0); EOL("End Mark");
@ -2778,7 +2784,9 @@ void DwarfDebug::emitDebugPubTypes() {
DIE * Entity = GI->second;
Asm->EmitInt32(Entity->getOffset()); EOL("DIE offset");
Asm->EmitString(Name, strlen(Name)); EOL("External Name");
if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("External Name");
Asm->OutStreamer.EmitBytes(StringRef(Name, strlen(Name)), 0);
}
Asm->EmitInt32(0); EOL("End Mark");
@ -2803,8 +2811,7 @@ void DwarfDebug::emitDebugStr() {
// Emit the string itself.
const std::string &String = StringPool[StringID];
Asm->EmitString(String);
Asm->O << '\n';
Asm->OutStreamer.EmitBytes(StringRef(String.c_str(), String.size()+1), 0);
}
Asm->O << '\n';
@ -2920,11 +2927,12 @@ void DwarfDebug::emitDebugInlineInfo() {
StringRef LName = SP.getLinkageName();
StringRef Name = SP.getName();
if (LName.empty())
Asm->EmitString(Name);
else
if (LName.empty()) {
Asm->OutStreamer.EmitBytes(Name, 0);
Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
} else
EmitSectionOffset("string", "section_str",
StringPool.idFor(getRealLinkageName(LName)), false, true);
StringPool.idFor(getRealLinkageName(LName)), false, true);
EOL("MIPS linkage name");
EmitSectionOffset("string", "section_str",

View File

@ -146,7 +146,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
unsigned LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
unsigned FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
char Augmentation[5] = { 0 };
char Augmentation[6] = { 0 };
unsigned AugmentationSize = 0;
char *APtr = Augmentation + 1;
@ -171,7 +171,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
if (APtr != Augmentation + 1)
Augmentation[0] = 'z';
Asm->EmitString(Augmentation);
Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
EOL("CIE Augmentation");
// Round out reader.