summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-22 07:00:50 +0000
committerChris Lattner <sabre@nondot.org>2007-05-22 07:00:50 +0000
commit83d7dd419ad5f8b2214a458a2a1589fa05789547 (patch)
tree967643849ceb583a3b3eb52b8e012059d6fead0e
parent9a0ff5961ba857c36835185d2a88cc7763fd3a6a (diff)
downloadbcm5719-llvm-83d7dd419ad5f8b2214a458a2a1589fa05789547.tar.gz
bcm5719-llvm-83d7dd419ad5f8b2214a458a2a1589fa05789547.zip
temporarily revert reid's asmwriter patch, it is missing the asmparser piece
that decodes the escape sequences, thus breaking all cases that use them. This fixes test/Assembler/2007-05-21-Escape.ll llvm-svn: 37284
-rw-r--r--llvm/lib/VMCore/AsmWriter.cpp52
1 files changed, 19 insertions, 33 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp
index 1d97d5c54f3..536b541dfa1 100644
--- a/llvm/lib/VMCore/AsmWriter.cpp
+++ b/llvm/lib/VMCore/AsmWriter.cpp
@@ -33,7 +33,6 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Streams.h"
#include <algorithm>
-#include <cctype>
using namespace llvm;
namespace llvm {
@@ -179,39 +178,17 @@ static SlotMachine *createSlotMachine(const Value *V) {
/// NameNeedsQuotes - Return true if the specified llvm name should be wrapped
/// with ""'s.
-static std::string QuoteNameIfNeeded(const std::string &Name) {
- std::string result;
- bool needsQuotes = Name[0] >= '0' && Name[0] <= '9';
- // Scan the name to see if it needs quotes and to replace funky chars with
- // their octal equivalent.
+static bool NameNeedsQuotes(const std::string &Name) {
+ if (Name[0] >= '0' && Name[0] <= '9') return true;
+ // Scan to see if we have any characters that are not on the "white list"
for (unsigned i = 0, e = Name.size(); i != e; ++i) {
char C = Name[i];
assert(C != '"' && "Illegal character in LLVM value name!");
- if (isalnum(C) || C == '-' || C == '.' || C == '_')
- result += C;
- else if (isprint(C)) {
- needsQuotes = true;
- result += C;
- } else {
- needsQuotes = true;
- result += "\\";
- char hex1 = (C >> 4) & 0x0F;
- if (hex1 < 10)
- result += hex1 + '0';
- else
- result += hex1 - 10 + 'A';
- char hex2 = C & 0x0F;
- if (hex2 < 10)
- result += hex2 + '0';
- else
- result += hex2 - 10 + 'A';
- }
- }
- if (needsQuotes) {
- result.insert(0,"\"");
- result += '"';
+ if ((C < 'a' || C > 'z') && (C < 'A' || C > 'Z') && (C < '0' || C > '9') &&
+ C != '-' && C != '.' && C != '_')
+ return true;
}
- return result;
+ return false;
}
enum PrefixType {
@@ -225,11 +202,20 @@ enum PrefixType {
/// surrounded with ""'s (if it has special chars in it).
static std::string getLLVMName(const std::string &Name, PrefixType Prefix) {
assert(!Name.empty() && "Cannot get empty name!");
+
+ // First character cannot start with a number...
+ if (NameNeedsQuotes(Name)) {
+ if (Prefix == GlobalPrefix)
+ return "@\"" + Name + "\"";
+ return "\"" + Name + "\"";
+ }
+
+ // If we get here, then the identifier is legal to use as a "VarID".
switch (Prefix) {
default: assert(0 && "Bad prefix!");
- case GlobalPrefix: return '@' + QuoteNameIfNeeded(Name);
- case LabelPrefix: return QuoteNameIfNeeded(Name);
- case LocalPrefix: return '%' + QuoteNameIfNeeded(Name);
+ case GlobalPrefix: return '@' + Name;
+ case LabelPrefix: return Name;
+ case LocalPrefix: return '%' + Name;
}
}
OpenPOWER on IntegriCloud