[llvm-commits] [llvm] r77258 - in /llvm/trunk: include/llvm/MC/MCStreamer.h include/llvm/Target/TargetAsmParser.h lib/MC/MCAsmStreamer.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmLexer.h tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h tools/llvm-mc/MC-X86Specific.cpp

Daniel Dunbar daniel at zuster.org
Mon Jul 27 14:49:56 PDT 2009


Author: ddunbar
Date: Mon Jul 27 16:49:56 2009
New Revision: 77258

URL: http://llvm.org/viewvc/llvm-project?rev=77258&view=rev
Log:
llvm-mc: Move AsmLexer::getCurStrVal to StringRef based API.
 - My DFS traversal of LLVM is, at least for now, nearly complete! :)

Modified:
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/include/llvm/Target/TargetAsmParser.h
    llvm/trunk/lib/MC/MCAsmStreamer.cpp
    llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
    llvm/trunk/tools/llvm-mc/AsmLexer.h
    llvm/trunk/tools/llvm-mc/AsmParser.cpp
    llvm/trunk/tools/llvm-mc/AsmParser.h
    llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Jul 27 16:49:56 2009
@@ -22,6 +22,7 @@
   class MCInst;
   class MCSection;
   class MCSymbol;
+  class StringRef;
   class raw_ostream;
 
   /// MCStreamer - Streaming machine code generation interface.  This interface
@@ -166,12 +167,11 @@
     /// @name Generating Data
     /// @{
 
-    /// EmitBytes - Emit @param Length bytes starting at @param Data into the
-    /// output.
+    /// EmitBytes - Emit the bytes in @param Data into the output.
     ///
     /// This is used to implement assembler directives such as .byte, .ascii,
     /// etc.
-    virtual void EmitBytes(const char *Data, unsigned Length) = 0;
+    virtual void EmitBytes(const StringRef &Data) = 0;
 
     /// EmitValue - Emit the expression @param Value into the output as a native
     /// integer of the given @param Size bytes.

Modified: llvm/trunk/include/llvm/Target/TargetAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmParser.h?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmParser.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmParser.h Mon Jul 27 16:49:56 2009
@@ -13,6 +13,7 @@
 namespace llvm {
 class MCAsmParser;
 class MCInst;
+class StringRef;
 class Target;
 
 /// TargetAsmParser - Generic interface to target specific assembly parsers.
@@ -42,7 +43,7 @@
   /// \param Name - The instruction name.
   /// \param Inst [out] - On success, the parsed instruction.
   /// \return True on failure.
-  virtual bool ParseInstruction(MCAsmParser &AP, const char *Name, 
+  virtual bool ParseInstruction(MCAsmParser &AP, const StringRef &Name, 
                                 MCInst &Inst) = 0;
 };
 

Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Mon Jul 27 16:49:56 2009
@@ -57,7 +57,7 @@
 
     virtual void AbortAssembly(const char *AbortReason = NULL);
 
-    virtual void EmitBytes(const char *Data, unsigned Length);
+    virtual void EmitBytes(const StringRef &Data);
 
     virtual void EmitValue(const MCValue &Value, unsigned Size);
 
@@ -208,9 +208,9 @@
   OS << '\n';
 }
 
-void MCAsmStreamer::EmitBytes(const char *Data, unsigned Length) {
+void MCAsmStreamer::EmitBytes(const StringRef &Data) {
   assert(CurSection && "Cannot emit contents before setting section!");
-  for (unsigned i = 0; i != Length; ++i)
+  for (unsigned i = 0, e = Data.size(); i != e; ++i)
     OS << ".byte " << (unsigned) Data[i] << '\n';
 }
 

Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Mon Jul 27 16:49:56 2009
@@ -21,14 +21,14 @@
   class X86ATTAsmParser : public TargetAsmParser {
     bool ParseOperand(X86Operand &Op);
     
-    bool MatchInstruction(const char *Name, 
+    bool MatchInstruction(const StringRef &Name, 
                           llvm::SmallVector<X86Operand, 3> &Operands,
                           MCInst &Inst);
 
   public:
     explicit X86ATTAsmParser(const Target &);
     
-    virtual bool ParseInstruction(MCAsmParser &AP, const char *Name, 
+    virtual bool ParseInstruction(MCAsmParser &AP, const StringRef &Name, 
                                   MCInst &Inst);
   };
 }
@@ -43,13 +43,13 @@
 }
 
 bool 
-X86ATTAsmParser::MatchInstruction(const char *Name, 
+X86ATTAsmParser::MatchInstruction(const StringRef &Name, 
                                   llvm::SmallVector<X86Operand, 3> &Operands,
                                   MCInst &Inst) {
   return false;
 }
 
-bool X86ATTAsmParser::ParseInstruction(MCAsmParser &AP, const char *Name, 
+bool X86ATTAsmParser::ParseInstruction(MCAsmParser &AP, const StringRef &Name, 
                                        MCInst &Inst) {
   llvm::SmallVector<X86Operand, 3> Operands;
   

Modified: llvm/trunk/tools/llvm-mc/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.h?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.h Mon Jul 27 16:49:56 2009
@@ -14,6 +14,7 @@
 #ifndef ASMLEXER_H
 #define ASMLEXER_H
 
+#include "llvm/ADT/StringRef.h"
 #include "llvm/MC/MCAsmLexer.h"
 #include "llvm/Support/DataTypes.h"
 #include <string>
@@ -84,8 +85,13 @@
   asmtok::TokKind getKind() const { return CurKind; }
   bool is(asmtok::TokKind K) const { return CurKind == K; }
   bool isNot(asmtok::TokKind K) const { return CurKind != K; }
-  
-  const char *getCurStrVal() const {
+
+  /// getCurStrVal - Get the string for the current token, this includes all
+  /// characters (for example, the quotes on strings) in the token.
+  ///
+  /// The returned StringRef points into the source manager's memory buffer, and
+  /// is safe to store across calls to Lex().
+  StringRef getCurStrVal() const {
     assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
             CurKind == asmtok::String) &&
            "This token doesn't have a string value");

Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Mon Jul 27 16:49:56 2009
@@ -313,7 +313,7 @@
   
   // If we have an identifier, handle it as the key symbol.
   SMLoc IDLoc = Lexer.getLoc();
-  const char *IDVal = Lexer.getCurStrVal();
+  StringRef IDVal = Lexer.getCurStrVal();
   
   // Consume the identifier, see what is after it.
   switch (Lexer.Lex()) {
@@ -353,194 +353,194 @@
   // Otherwise, we have a normal instruction or directive.  
   if (IDVal[0] == '.') {
     // FIXME: This should be driven based on a hash lookup and callback.
-    if (!strcmp(IDVal, ".section"))
+    if (IDVal == ".section")
       return ParseDirectiveDarwinSection();
-    if (!strcmp(IDVal, ".text"))
+    if (IDVal == ".text")
       // FIXME: This changes behavior based on the -static flag to the
       // assembler.
       return ParseDirectiveSectionSwitch("__TEXT,__text",
                                          "regular,pure_instructions");
-    if (!strcmp(IDVal, ".const"))
+    if (IDVal == ".const")
       return ParseDirectiveSectionSwitch("__TEXT,__const");
-    if (!strcmp(IDVal, ".static_const"))
+    if (IDVal == ".static_const")
       return ParseDirectiveSectionSwitch("__TEXT,__static_const");
-    if (!strcmp(IDVal, ".cstring"))
+    if (IDVal == ".cstring")
       return ParseDirectiveSectionSwitch("__TEXT,__cstring", 
                                          "cstring_literals");
-    if (!strcmp(IDVal, ".literal4"))
+    if (IDVal == ".literal4")
       return ParseDirectiveSectionSwitch("__TEXT,__literal4", "4byte_literals");
-    if (!strcmp(IDVal, ".literal8"))
+    if (IDVal == ".literal8")
       return ParseDirectiveSectionSwitch("__TEXT,__literal8", "8byte_literals");
-    if (!strcmp(IDVal, ".literal16"))
+    if (IDVal == ".literal16")
       return ParseDirectiveSectionSwitch("__TEXT,__literal16",
                                          "16byte_literals");
-    if (!strcmp(IDVal, ".constructor"))
+    if (IDVal == ".constructor")
       return ParseDirectiveSectionSwitch("__TEXT,__constructor");
-    if (!strcmp(IDVal, ".destructor"))
+    if (IDVal == ".destructor")
       return ParseDirectiveSectionSwitch("__TEXT,__destructor");
-    if (!strcmp(IDVal, ".fvmlib_init0"))
+    if (IDVal == ".fvmlib_init0")
       return ParseDirectiveSectionSwitch("__TEXT,__fvmlib_init0");
-    if (!strcmp(IDVal, ".fvmlib_init1"))
+    if (IDVal == ".fvmlib_init1")
       return ParseDirectiveSectionSwitch("__TEXT,__fvmlib_init1");
-    if (!strcmp(IDVal, ".symbol_stub")) // FIXME: Different on PPC.
+    if (IDVal == ".symbol_stub") // FIXME: Different on PPC.
       return ParseDirectiveSectionSwitch("__IMPORT,__jump_table,symbol_stubs",
                                     "self_modifying_code+pure_instructions,5");
     // FIXME: .picsymbol_stub on PPC.
-    if (!strcmp(IDVal, ".data"))
+    if (IDVal == ".data")
       return ParseDirectiveSectionSwitch("__DATA,__data");
-    if (!strcmp(IDVal, ".static_data"))
+    if (IDVal == ".static_data")
       return ParseDirectiveSectionSwitch("__DATA,__static_data");
-    if (!strcmp(IDVal, ".non_lazy_symbol_pointer"))
+    if (IDVal == ".non_lazy_symbol_pointer")
       return ParseDirectiveSectionSwitch("__DATA,__nl_symbol_pointer",
                                          "non_lazy_symbol_pointers");
-    if (!strcmp(IDVal, ".lazy_symbol_pointer"))
+    if (IDVal == ".lazy_symbol_pointer")
       return ParseDirectiveSectionSwitch("__DATA,__la_symbol_pointer",
                                          "lazy_symbol_pointers");
-    if (!strcmp(IDVal, ".dyld"))
+    if (IDVal == ".dyld")
       return ParseDirectiveSectionSwitch("__DATA,__dyld");
-    if (!strcmp(IDVal, ".mod_init_func"))
+    if (IDVal == ".mod_init_func")
       return ParseDirectiveSectionSwitch("__DATA,__mod_init_func",
                                          "mod_init_funcs");
-    if (!strcmp(IDVal, ".mod_term_func"))
+    if (IDVal == ".mod_term_func")
       return ParseDirectiveSectionSwitch("__DATA,__mod_term_func",
                                          "mod_term_funcs");
-    if (!strcmp(IDVal, ".const_data"))
+    if (IDVal == ".const_data")
       return ParseDirectiveSectionSwitch("__DATA,__const", "regular");
     
     
     // FIXME: Verify attributes on sections.
-    if (!strcmp(IDVal, ".objc_class"))
+    if (IDVal == ".objc_class")
       return ParseDirectiveSectionSwitch("__OBJC,__class");
-    if (!strcmp(IDVal, ".objc_meta_class"))
+    if (IDVal == ".objc_meta_class")
       return ParseDirectiveSectionSwitch("__OBJC,__meta_class");
-    if (!strcmp(IDVal, ".objc_cat_cls_meth"))
+    if (IDVal == ".objc_cat_cls_meth")
       return ParseDirectiveSectionSwitch("__OBJC,__cat_cls_meth");
-    if (!strcmp(IDVal, ".objc_cat_inst_meth"))
+    if (IDVal == ".objc_cat_inst_meth")
       return ParseDirectiveSectionSwitch("__OBJC,__cat_inst_meth");
-    if (!strcmp(IDVal, ".objc_protocol"))
+    if (IDVal == ".objc_protocol")
       return ParseDirectiveSectionSwitch("__OBJC,__protocol");
-    if (!strcmp(IDVal, ".objc_string_object"))
+    if (IDVal == ".objc_string_object")
       return ParseDirectiveSectionSwitch("__OBJC,__string_object");
-    if (!strcmp(IDVal, ".objc_cls_meth"))
+    if (IDVal == ".objc_cls_meth")
       return ParseDirectiveSectionSwitch("__OBJC,__cls_meth");
-    if (!strcmp(IDVal, ".objc_inst_meth"))
+    if (IDVal == ".objc_inst_meth")
       return ParseDirectiveSectionSwitch("__OBJC,__inst_meth");
-    if (!strcmp(IDVal, ".objc_cls_refs"))
+    if (IDVal == ".objc_cls_refs")
       return ParseDirectiveSectionSwitch("__OBJC,__cls_refs");
-    if (!strcmp(IDVal, ".objc_message_refs"))
+    if (IDVal == ".objc_message_refs")
       return ParseDirectiveSectionSwitch("__OBJC,__message_refs");
-    if (!strcmp(IDVal, ".objc_symbols"))
+    if (IDVal == ".objc_symbols")
       return ParseDirectiveSectionSwitch("__OBJC,__symbols");
-    if (!strcmp(IDVal, ".objc_category"))
+    if (IDVal == ".objc_category")
       return ParseDirectiveSectionSwitch("__OBJC,__category");
-    if (!strcmp(IDVal, ".objc_class_vars"))
+    if (IDVal == ".objc_class_vars")
       return ParseDirectiveSectionSwitch("__OBJC,__class_vars");
-    if (!strcmp(IDVal, ".objc_instance_vars"))
+    if (IDVal == ".objc_instance_vars")
       return ParseDirectiveSectionSwitch("__OBJC,__instance_vars");
-    if (!strcmp(IDVal, ".objc_module_info"))
+    if (IDVal == ".objc_module_info")
       return ParseDirectiveSectionSwitch("__OBJC,__module_info");
-    if (!strcmp(IDVal, ".objc_class_names"))
+    if (IDVal == ".objc_class_names")
       return ParseDirectiveSectionSwitch("__TEXT,__cstring","cstring_literals");
-    if (!strcmp(IDVal, ".objc_meth_var_types"))
+    if (IDVal == ".objc_meth_var_types")
       return ParseDirectiveSectionSwitch("__TEXT,__cstring","cstring_literals");
-    if (!strcmp(IDVal, ".objc_meth_var_names"))
+    if (IDVal == ".objc_meth_var_names")
       return ParseDirectiveSectionSwitch("__TEXT,__cstring","cstring_literals");
-    if (!strcmp(IDVal, ".objc_selector_strs"))
+    if (IDVal == ".objc_selector_strs")
       return ParseDirectiveSectionSwitch("__OBJC,__selector_strs");
     
     // Assembler features
-    if (!strcmp(IDVal, ".set"))
+    if (IDVal == ".set")
       return ParseDirectiveSet();
 
     // Data directives
 
-    if (!strcmp(IDVal, ".ascii"))
+    if (IDVal == ".ascii")
       return ParseDirectiveAscii(false);
-    if (!strcmp(IDVal, ".asciz"))
+    if (IDVal == ".asciz")
       return ParseDirectiveAscii(true);
 
     // FIXME: Target hooks for size? Also for "word", "hword".
-    if (!strcmp(IDVal, ".byte"))
+    if (IDVal == ".byte")
       return ParseDirectiveValue(1);
-    if (!strcmp(IDVal, ".short"))
+    if (IDVal == ".short")
       return ParseDirectiveValue(2);
-    if (!strcmp(IDVal, ".long"))
+    if (IDVal == ".long")
       return ParseDirectiveValue(4);
-    if (!strcmp(IDVal, ".quad"))
+    if (IDVal == ".quad")
       return ParseDirectiveValue(8);
 
     // FIXME: Target hooks for IsPow2.
-    if (!strcmp(IDVal, ".align"))
+    if (IDVal == ".align")
       return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/1);
-    if (!strcmp(IDVal, ".align32"))
+    if (IDVal == ".align32")
       return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/4);
-    if (!strcmp(IDVal, ".balign"))
+    if (IDVal == ".balign")
       return ParseDirectiveAlign(/*IsPow2=*/false, /*ExprSize=*/1);
-    if (!strcmp(IDVal, ".balignw"))
+    if (IDVal == ".balignw")
       return ParseDirectiveAlign(/*IsPow2=*/false, /*ExprSize=*/2);
-    if (!strcmp(IDVal, ".balignl"))
+    if (IDVal == ".balignl")
       return ParseDirectiveAlign(/*IsPow2=*/false, /*ExprSize=*/4);
-    if (!strcmp(IDVal, ".p2align"))
+    if (IDVal == ".p2align")
       return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/1);
-    if (!strcmp(IDVal, ".p2alignw"))
+    if (IDVal == ".p2alignw")
       return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/2);
-    if (!strcmp(IDVal, ".p2alignl"))
+    if (IDVal == ".p2alignl")
       return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/4);
 
-    if (!strcmp(IDVal, ".org"))
+    if (IDVal == ".org")
       return ParseDirectiveOrg();
 
-    if (!strcmp(IDVal, ".fill"))
+    if (IDVal == ".fill")
       return ParseDirectiveFill();
-    if (!strcmp(IDVal, ".space"))
+    if (IDVal == ".space")
       return ParseDirectiveSpace();
 
     // Symbol attribute directives
-    if (!strcmp(IDVal, ".globl") || !strcmp(IDVal, ".global"))
+    if (IDVal == ".globl" || IDVal == ".global")
       return ParseDirectiveSymbolAttribute(MCStreamer::Global);
-    if (!strcmp(IDVal, ".hidden"))
+    if (IDVal == ".hidden")
       return ParseDirectiveSymbolAttribute(MCStreamer::Hidden);
-    if (!strcmp(IDVal, ".indirect_symbol"))
+    if (IDVal == ".indirect_symbol")
       return ParseDirectiveSymbolAttribute(MCStreamer::IndirectSymbol);
-    if (!strcmp(IDVal, ".internal"))
+    if (IDVal == ".internal")
       return ParseDirectiveSymbolAttribute(MCStreamer::Internal);
-    if (!strcmp(IDVal, ".lazy_reference"))
+    if (IDVal == ".lazy_reference")
       return ParseDirectiveSymbolAttribute(MCStreamer::LazyReference);
-    if (!strcmp(IDVal, ".no_dead_strip"))
+    if (IDVal == ".no_dead_strip")
       return ParseDirectiveSymbolAttribute(MCStreamer::NoDeadStrip);
-    if (!strcmp(IDVal, ".private_extern"))
+    if (IDVal == ".private_extern")
       return ParseDirectiveSymbolAttribute(MCStreamer::PrivateExtern);
-    if (!strcmp(IDVal, ".protected"))
+    if (IDVal == ".protected")
       return ParseDirectiveSymbolAttribute(MCStreamer::Protected);
-    if (!strcmp(IDVal, ".reference"))
+    if (IDVal == ".reference")
       return ParseDirectiveSymbolAttribute(MCStreamer::Reference);
-    if (!strcmp(IDVal, ".weak"))
+    if (IDVal == ".weak")
       return ParseDirectiveSymbolAttribute(MCStreamer::Weak);
-    if (!strcmp(IDVal, ".weak_definition"))
+    if (IDVal == ".weak_definition")
       return ParseDirectiveSymbolAttribute(MCStreamer::WeakDefinition);
-    if (!strcmp(IDVal, ".weak_reference"))
+    if (IDVal == ".weak_reference")
       return ParseDirectiveSymbolAttribute(MCStreamer::WeakReference);
 
-    if (!strcmp(IDVal, ".comm"))
+    if (IDVal == ".comm")
       return ParseDirectiveComm(/*IsLocal=*/false);
-    if (!strcmp(IDVal, ".lcomm"))
+    if (IDVal == ".lcomm")
       return ParseDirectiveComm(/*IsLocal=*/true);
-    if (!strcmp(IDVal, ".zerofill"))
+    if (IDVal == ".zerofill")
       return ParseDirectiveDarwinZerofill();
-    if (!strcmp(IDVal, ".desc"))
+    if (IDVal == ".desc")
       return ParseDirectiveDarwinSymbolDesc();
-    if (!strcmp(IDVal, ".lsym"))
+    if (IDVal == ".lsym")
       return ParseDirectiveDarwinLsym();
 
-    if (!strcmp(IDVal, ".subsections_via_symbols"))
+    if (IDVal == ".subsections_via_symbols")
       return ParseDirectiveDarwinSubsectionsViaSymbols();
-    if (!strcmp(IDVal, ".abort"))
+    if (IDVal == ".abort")
       return ParseDirectiveAbort();
-    if (!strcmp(IDVal, ".include"))
+    if (IDVal == ".include")
       return ParseDirectiveInclude();
-    if (!strcmp(IDVal, ".dump"))
+    if (IDVal == ".dump")
       return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsDump=*/true);
-    if (!strcmp(IDVal, ".load"))
+    if (IDVal == ".load")
       return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsLoad=*/false);
 
     Warning(IDLoc, "ignoring directive for now");
@@ -566,7 +566,7 @@
   return false;
 }
 
-bool AsmParser::ParseAssignment(const char *Name, bool IsDotSet) {
+bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
   // FIXME: Use better location, we should use proper tokens.
   SMLoc EqualLoc = Lexer.getLoc();
 
@@ -605,7 +605,7 @@
   if (Lexer.isNot(asmtok::Identifier))
     return TokError("expected identifier after '.set' directive");
 
-  const char *Name = Lexer.getCurStrVal();
+  StringRef Name = Lexer.getCurStrVal();
   
   if (Lexer.Lex() != asmtok::Comma)
     return TokError("unexpected token in '.set'");
@@ -632,7 +632,7 @@
     if (Lexer.isNot(asmtok::Identifier))
       return TokError("expected identifier in '.section' directive");
     Section += ',';
-    Section += Lexer.getCurStrVal();
+    Section += Lexer.getCurStrVal().str();
     Lexer.Lex();
   }
   
@@ -671,10 +671,10 @@
       // FIXME: This shouldn't use a const char* + strlen, the string could have
       // embedded nulls.
       // FIXME: Should have accessor for getting string contents.
-      const char *Str = Lexer.getCurStrVal();
-      Out.EmitBytes(Str + 1, strlen(Str) - 2);
+      StringRef Str = Lexer.getCurStrVal();
+      Out.EmitBytes(Str.substr(1, Str.size() - 2));
       if (ZeroTerminated)
-        Out.EmitBytes("\0", 1);
+        Out.EmitBytes(StringRef("\0", 1));
       
       Lexer.Lex();
       
@@ -1026,7 +1026,7 @@
   if (Lexer.isNot(asmtok::Identifier))
     return TokError("expected section name after comma in '.zerofill' "
                     "directive");
-  Section += Lexer.getCurStrVal();
+  Section += Lexer.getCurStrVal().str();
   Lexer.Lex();
 
   // FIXME: we will need to tell GetSection() that this is to be created with or
@@ -1117,7 +1117,7 @@
 /// ParseDirectiveAbort
 ///  ::= .abort [ "abort_string" ]
 bool AsmParser::ParseDirectiveAbort() {
-  const char *Str = NULL;
+  StringRef Str = "";
   if (Lexer.isNot(asmtok::EndOfStatement)) {
     if (Lexer.isNot(asmtok::String))
       return TokError("expected string in '.abort' directive");
@@ -1132,7 +1132,8 @@
   
   Lexer.Lex();
 
-  Out.AbortAssembly(Str);
+  // FIXME: Handle here.
+  Out.AbortAssembly(Str.str().c_str());
 
   return false;
 }

Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Mon Jul 27 16:49:56 2009
@@ -58,7 +58,7 @@
   
   void EatToEndOfStatement();
   
-  bool ParseAssignment(const char *Name, bool IsDotSet);
+  bool ParseAssignment(const StringRef &Name, bool IsDotSet);
 
   /// ParseExpression - Parse a general assembly expression.
   ///
@@ -97,7 +97,7 @@
   bool ParseParenExpr(AsmExpr *&Res);
   
   // X86 specific.
-  bool ParseX86InstOperands(const char *InstName, MCInst &Inst);
+  bool ParseX86InstOperands(const StringRef &InstName, MCInst &Inst);
   bool ParseX86Operand(X86Operand &Op);
   bool ParseX86MemOperand(X86Operand &Op);
   bool ParseX86Register(X86Operand &Op);

Modified: llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp?rev=77258&r1=77257&r2=77258&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp (original)
+++ llvm/trunk/tools/llvm-mc/MC-X86Specific.cpp Mon Jul 27 16:49:56 2009
@@ -235,7 +235,7 @@
 
 /// MatchX86Inst - Convert a parsed instruction name and operand list into a
 /// concrete instruction.
-static bool MatchX86Inst(const char *Name, 
+static bool MatchX86Inst(const StringRef &Name, 
                          llvm::SmallVector<AsmParser::X86Operand, 3> &Operands,
                          MCInst &Inst) {
   return false;
@@ -243,7 +243,7 @@
 
 /// ParseX86InstOperands - Parse the operands of an X86 instruction and return
 /// them as the operands of an MCInst.
-bool AsmParser::ParseX86InstOperands(const char *InstName, MCInst &Inst) {
+bool AsmParser::ParseX86InstOperands(const StringRef &InstName, MCInst &Inst) {
   llvm::SmallVector<X86Operand, 3> Operands;
 
   if (Lexer.isNot(asmtok::EndOfStatement)) {





More information about the llvm-commits mailing list