<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 1, 2016, at 8:08 AM, Zachary Turner <<a href="mailto:zturner@google.com" class="">zturner@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Sep 30, 2016 at 11:55 PM Mehdi Amini via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: mehdi_amini<br class="gmail_msg">Date: Sat Oct  1 01:46:33 2016<br class="gmail_msg">New Revision: 283018<br class="gmail_msg"><br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=283018&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=283018&view=rev</a><br class="gmail_msg">Log:<br class="gmail_msg">Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)<br class="gmail_msg"><br class="gmail_msg">Modified:<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/MC/MCAsmInfo.h<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/MC/MCInstrInfo.h<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/MC/MCParser/AsmLexer.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/Mips/Mips16InstrInfo.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h<br class="gmail_msg">   <span class="Apple-converted-space"> </span>llvm/trunk/tools/llvm-objdump/MachODump.cpp<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)<br class="gmail_msg">+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -103,7 +103,7 @@ protected:<br class="gmail_msg"><br class="gmail_msg">   /// This indicates the comment character used by the assembler.  Defaults to<br class="gmail_msg">   /// "#"<br class="gmail_msg">-  const char *CommentString;<br class="gmail_msg">+  StringRef CommentString;<br class="gmail_msg"><br class="gmail_msg">   /// This is appended to emitted labels.  Defaults to ":"<br class="gmail_msg">   const char *LabelSuffix;<br class="gmail_msg">@@ -117,17 +117,17 @@ protected:<br class="gmail_msg">   /// This prefix is used for globals like constant pool entries that are<br class="gmail_msg">   /// completely private to the .s file and should not have names in the .o<br class="gmail_msg">   /// file.  Defaults to "L"<br class="gmail_msg">-  const char *PrivateGlobalPrefix;<br class="gmail_msg">+  StringRef PrivateGlobalPrefix;<br class="gmail_msg"><br class="gmail_msg">   /// This prefix is used for labels for basic blocks. Defaults to the same as<br class="gmail_msg">   /// PrivateGlobalPrefix.<br class="gmail_msg">-  const char *PrivateLabelPrefix;<br class="gmail_msg">+  StringRef PrivateLabelPrefix;<br class="gmail_msg"><br class="gmail_msg">   /// This prefix is used for symbols that should be passed through the<br class="gmail_msg">   /// assembler but be removed by the linker.  This is 'l' on Darwin, currently<br class="gmail_msg">   /// used for some ObjC metadata.  The default of "" meast that for this system<br class="gmail_msg">   /// a plain private symbol should be used.  Defaults to "".<br class="gmail_msg">-  const char *LinkerPrivateGlobalPrefix;<br class="gmail_msg">+  StringRef LinkerPrivateGlobalPrefix;<br class="gmail_msg"><br class="gmail_msg">   /// If these are nonempty, they contain a directive to emit before and after<br class="gmail_msg">   /// an inline assembly statement.  Defaults to "#APP\n", "#NO_APP\n"<br class="gmail_msg">@@ -468,17 +468,17 @@ public:<br class="gmail_msg">   /// printed.<br class="gmail_msg">   unsigned getCommentColumn() const { return 40; }<br class="gmail_msg"><br class="gmail_msg">-  const char *getCommentString() const { return CommentString; }<br class="gmail_msg">+  StringRef getCommentString() const { return CommentString; }<br class="gmail_msg">   const char *getLabelSuffix() const { return LabelSuffix; }<br class="gmail_msg"><br class="gmail_msg">   bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }<br class="gmail_msg">   bool needsLocalForSize() const { return NeedsLocalForSize; }<br class="gmail_msg">-  const char *getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }<br class="gmail_msg">-  const char *getPrivateLabelPrefix() const { return PrivateLabelPrefix; }<br class="gmail_msg">+  StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }<br class="gmail_msg">+  StringRef getPrivateLabelPrefix() const { return PrivateLabelPrefix; }<br class="gmail_msg">   bool hasLinkerPrivateGlobalPrefix() const {<br class="gmail_msg">     return LinkerPrivateGlobalPrefix[0] != '\0';<br class="gmail_msg">   }<br class="gmail_msg">-  const char *getLinkerPrivateGlobalPrefix() const {<br class="gmail_msg">+  StringRef getLinkerPrivateGlobalPrefix() const {<br class="gmail_msg">     if (hasLinkerPrivateGlobalPrefix())<br class="gmail_msg">       return LinkerPrivateGlobalPrefix;<br class="gmail_msg">     return getPrivateGlobalPrefix();<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/include/llvm/MC/MCInstrInfo.h<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInstrInfo.h?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInstrInfo.h?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/include/llvm/MC/MCInstrInfo.h (original)<br class="gmail_msg">+++ llvm/trunk/include/llvm/MC/MCInstrInfo.h Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -48,9 +48,9 @@ public:<br class="gmail_msg">   }<br class="gmail_msg"><br class="gmail_msg">   /// \brief Returns the name for the instructions with the given opcode.<br class="gmail_msg">-  const char *getName(unsigned Opcode) const {<br class="gmail_msg">+  StringRef getName(unsigned Opcode) const {<br class="gmail_msg">     assert(Opcode < NumOpcodes && "Invalid opcode!");<br class="gmail_msg">-    return &InstrNameData[InstrNameIndices[Opcode]];<br class="gmail_msg">+    return StringRef(&InstrNameData[InstrNameIndices[Opcode]]);<br class="gmail_msg">   }<br class="gmail_msg"> };<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -51,7 +51,7 @@ MCSymbol *MachineBasicBlock::getSymbol()<br class="gmail_msg">   if (!CachedMCSymbol) {<br class="gmail_msg">     const MachineFunction *MF = getParent();<br class="gmail_msg">     MCContext &Ctx = MF->getContext();<br class="gmail_msg">-    const char *Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();<br class="gmail_msg">+    auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();<br class="gmail_msg">     assert(getNumber() >= 0 && "cannot get label for unreachable MBB");<br class="gmail_msg">     CachedMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB" +<br class="gmail_msg">                                           <span class="Apple-converted-space"> </span>Twine(MF->getFunctionNumber()) +<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -84,8 +84,8 @@ unsigned TargetInstrInfo::getInlineAsmLe<br class="gmail_msg">     if (*Str == '\n' || strncmp(Str, MAI.getSeparatorString(),<br class="gmail_msg">                                 strlen(MAI.getSeparatorString())) == 0) {<br class="gmail_msg">       atInsnStart = true;<br class="gmail_msg">-    } else if (strncmp(Str, MAI.getCommentString(),<br class="gmail_msg">-                       strlen(MAI.getCommentString())) == 0) {<br class="gmail_msg">+    } else if (strncmp(Str, MAI.getCommentString().data(),<br class="gmail_msg">+                       MAI.getCommentString().size()) == 0) {<br class="gmail_msg"></blockquote><div class="">This should be "MAI.getCommentString() == Str”</div></div></div></div></blockquote><div><br class=""></div><div>This implies building a StringRef with Str which means that 1) you need to be sure that Str is null terminated, and 2) you’ll run strlen on Str before doing a str compare, and 3) the most important, the original comparison matches that Str *starts with* getCommentString() while your replacement is an exact match.</div><div>So the correct replacement would be `StringRef(Str).startwith(MAI.getCommentString())`, with the two drawbacks above.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">       // Stop counting as an instruction after a comment unt </blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">il the next<br class="gmail_msg">       // separator.<br class="gmail_msg">       atInsnStart = false;<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -138,7 +138,7 @@ static void emitComments(LLVMDisasmConte<br class="gmail_msg">   StringRef Comments = DC->CommentsToEmit.str();<br class="gmail_msg">   // Get the default information for printing a comment.<br class="gmail_msg">   const MCAsmInfo *MAI = DC->getAsmInfo();<br class="gmail_msg">-  const char *CommentBegin = MAI->getCommentString();<br class="gmail_msg">+  StringRef CommentBegin = MAI->getCommentString();<br class="gmail_msg">   unsigned CommentColumn = MAI->getCommentColumn();<br class="gmail_msg">   bool IsFirst = true;<br class="gmail_msg">   while (!Comments.empty()) {<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -511,16 +511,16 @@ size_t AsmLexer::peekTokens(MutableArray<br class="gmail_msg"> }<br class="gmail_msg"><br class="gmail_msg"> bool AsmLexer::isAtStartOfComment(const char *Ptr) {<br class="gmail_msg">-  const char *CommentString = MAI.getCommentString();<br class="gmail_msg">+  StringRef CommentString = MAI.getCommentString();<br class="gmail_msg"><br class="gmail_msg">-  if (CommentString[1] == '\0')<br class="gmail_msg">+  if (CommentString.size() == 1) </blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">     return CommentString[0] == Ptr[0];<br class="gmail_msg"><br class="gmail_msg">   // Allow # preprocessor commments also be counted as comments for "##" cases<br class="gmail_msg">   if (CommentString[1] == '#')<br class="gmail_msg">     return CommentString[0] == Ptr[0];<br class="gmail_msg"><br class="gmail_msg">-  return strncmp(Ptr, CommentString, strlen(CommentString)) == 0;<br class="gmail_msg">+  return strncmp(Ptr, CommentString.data(), CommentString.size()) == 0;<br class="gmail_msg"></blockquote><div class="">operator ==</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> }<br class="gmail_msg"><br class="gmail_msg"> bool AsmLexer::isAtStatementSeparator(const char *Ptr) {<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -1541,8 +1541,8 @@ unsigned HexagonInstrInfo::getInlineAsmL<br class="gmail_msg">       Length += MAI.getMaxInstLength();<br class="gmail_msg">       atInsnStart = false;<br class="gmail_msg">     }<br class="gmail_msg">-    if (atInsnStart && strncmp(Str, MAI.getCommentString(),<br class="gmail_msg">-                               strlen(MAI.getCommentString())) == 0)<br class="gmail_msg">+    if (atInsnStart && strncmp(Str, MAI.getCommentString().data(),<br class="gmail_msg">+                               MAI.getCommentString().size()) == 0)<br class="gmail_msg"></blockquote><div class="">operator==</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">       atInsnStart = false;<br class="gmail_msg">   }<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -306,7 +306,7 @@ int HexagonMCInstrInfo::getMinValue(MCIn<br class="gmail_msg">     return 0;<br class="gmail_msg"> }<br class="gmail_msg"><br class="gmail_msg">-char const *HexagonMCInstrInfo::getName(MCInstrInfo const &MCII,<br class="gmail_msg">+StringRef HexagonMCInstrInfo::getName(MCInstrInfo const &MCII,<br class="gmail_msg">                                         MCInst const &MCI) {<br class="gmail_msg">   return MCII.getName(MCI.getOpcode());<br class="gmail_msg"> }<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -133,7 +133,7 @@ int getMaxValue(MCInstrInfo const &MCII,<br class="gmail_msg"> int getMinValue(MCInstrInfo const &MCII, MCInst const &MCI);<br class="gmail_msg"><br class="gmail_msg"> // Return instruction name<br class="gmail_msg">-char const *getName(MCInstrInfo const &MCII, MCInst const &MCI);<br class="gmail_msg">+StringRef getName(MCInstrInfo const &MCII, MCInst const &MCI);<br class="gmail_msg"><br class="gmail_msg"> // Return the operand index for the new value.<br class="gmail_msg"> unsigned short getNewValueOp(MCInstrInfo const &MCII, MCInst const &MCI);<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/Mips/Mips16InstrInfo.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips16InstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips16InstrInfo.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/Mips/Mips16InstrInfo.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/Mips/Mips16InstrInfo.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -510,8 +510,8 @@ unsigned Mips16InstrInfo::getInlineAsmLe<br class="gmail_msg">       Length += MAI.getMaxInstLength();<br class="gmail_msg">       atInsnStart = false;<br class="gmail_msg">     }<br class="gmail_msg">-    if (atInsnStart && strncmp(Str, MAI.getCommentString(),<br class="gmail_msg">-                               strlen(MAI.getCommentString())) == 0)<br class="gmail_msg">+    if (atInsnStart && strncmp(Str, MAI.getCommentString().data(),<br class="gmail_msg">+                               MAI.getCommentString().size()) == 0)<br class="gmail_msg"></blockquote><div class="">operator==</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">       atInsnStart = false;<br class="gmail_msg">   }<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -96,7 +96,7 @@ void llvm::X86Disassembler::Debug(const<br class="gmail_msg">   dbgs() << file << ":" << line << ": " << s;<br class="gmail_msg"> }<br class="gmail_msg"><br class="gmail_msg">-const char *llvm::X86Disassembler::GetInstrName(unsigned Opcode,<br class="gmail_msg">+StringRef llvm::X86Disassembler::GetInstrName(unsigned Opcode,<br class="gmail_msg">                                                 const void *mii) {<br class="gmail_msg">   const MCInstrInfo *MII = static_cast<const MCInstrInfo *>(mii);<br class="gmail_msg">   return MII->getName(Opcode);<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -825,7 +825,7 @@ static int getIDWithAttrMask(uint16_t* i<br class="gmail_msg"> <span class="Apple-converted-space"> </span>* @param orig  - The instruction that is not 16-bit<br class="gmail_msg"> <span class="Apple-converted-space"> </span>* @param equiv - The instruction that is 16-bit<br class="gmail_msg"> <span class="Apple-converted-space"> </span>*/<br class="gmail_msg">-static bool is16BitEquivalent(const char* orig, const char* equiv) {<br class="gmail_msg">+static bool is16BitEquivalent(const char *orig, const char *equiv) {<br class="gmail_msg">   off_t i;<br class="gmail_msg"><br class="gmail_msg">   for (i = 0;; i++) {<br class="gmail_msg">@@ -850,7 +850,7 @@ static bool is16BitEquivalent(const char<br class="gmail_msg"> <span class="Apple-converted-space"> </span>*<br class="gmail_msg"> <span class="Apple-converted-space"> </span>* @param name - The instruction that is not 16-bit<br class="gmail_msg"> <span class="Apple-converted-space"> </span>*/<br class="gmail_msg">-static bool is64Bit(const char* name) {<br class="gmail_msg">+static bool is64Bit(const char *name) {<br class="gmail_msg">   off_t i;<br class="gmail_msg"><br class="gmail_msg">   for (i = 0;; ++i) {<br class="gmail_msg">@@ -1044,9 +1044,9 @@ static int getID(struct InternalInstruct<br class="gmail_msg">         return 0;<br class="gmail_msg">       }<br class="gmail_msg"><br class="gmail_msg">-      const char *SpecName = GetInstrName(instructionIDWithREXW, miiArg);<br class="gmail_msg">+      auto SpecName = GetInstrName(instructionIDWithREXW, miiArg);<br class="gmail_msg">       // If not a 64-bit instruction. Switch the opcode.<br class="gmail_msg">-      if (!is64Bit(SpecName)) {<br class="gmail_msg">+      if (!is64Bit(SpecName.data())) {<br class="gmail_msg">         insn->instructionID = instructionIDWithREXW;<br class="gmail_msg">         insn->spec = specifierForUID(instructionIDWithREXW);<br class="gmail_msg">         return 0;<br class="gmail_msg">@@ -1092,7 +1092,7 @@ static int getID(struct InternalInstruct<br class="gmail_msg"><br class="gmail_msg">     const struct InstructionSpecifier *spec;<br class="gmail_msg">     uint16_t instructionIDWithOpsize;<br class="gmail_msg">-    const char *specName, *specWithOpSizeName;<br class="gmail_msg">+    llvm::StringRef specName, specWithOpSizeName;<br class="gmail_msg"><br class="gmail_msg">     spec = specifierForUID(instructionID);<br class="gmail_msg"><br class="gmail_msg">@@ -1112,7 +1112,7 @@ static int getID(struct InternalInstruct<br class="gmail_msg">     specName = GetInstrName(instructionID, miiArg);<br class="gmail_msg">     specWithOpSizeName = GetInstrName(instructionIDWithOpsize, miiArg);<br class="gmail_msg"><br class="gmail_msg">-    if (is16BitEquivalent(specName, specWithOpSizeName) &&<br class="gmail_msg">+    if (is16BitEquivalent(specName.data(), specWithOpSizeName.data()) &&<br class="gmail_msg">         (insn->mode == MODE_16BIT) ^ insn->prefixPresent[0x66]) {<br class="gmail_msg">       insn->instructionID = instructionIDWithOpsize;<br class="gmail_msg">       insn->spec = specifierForUID(instructionIDWithOpsize);<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h (original)<br class="gmail_msg">+++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -674,7 +674,7 @@ int decodeInstruction(InternalInstructio<br class="gmail_msg"> /// \param s    The message to print.<br class="gmail_msg"> void Debug(const char *file, unsigned line, const char *s);<br class="gmail_msg"><br class="gmail_msg">-const char *GetInstrName(unsigned Opcode, const void *mii);<br class="gmail_msg">+StringRef GetInstrName(unsigned Opcode, const void *mii);<br class="gmail_msg"><br class="gmail_msg"> } // namespace X86Disassembler<br class="gmail_msg"> } // namespace llvm<br class="gmail_msg"><br class="gmail_msg">Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp<br class="gmail_msg">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=283018&r1=283017&r2=283018&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=283018&r1=283017&r2=283018&view=diff</a><br class="gmail_msg">==============================================================================<br class="gmail_msg">--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)<br class="gmail_msg">+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Sat Oct  1 01:46:33 2016<br class="gmail_msg">@@ -6397,7 +6397,7 @@ static void emitComments(raw_svector_ost<br class="gmail_msg">   // Flush the stream before taking its content.<br class="gmail_msg">   StringRef Comments = CommentsToEmit.str();<br class="gmail_msg">   // Get the default information for printing a comment.<br class="gmail_msg">-  const char *CommentBegin = MAI.getCommentString();<br class="gmail_msg">+  StringRef CommentBegin = MAI.getCommentString();<br class="gmail_msg">   unsigned CommentColumn = MAI.getCommentColumn();<br class="gmail_msg">   bool IsFirst = true;<br class="gmail_msg">   while (!Comments.empty()) {<br class="gmail_msg"><br class="gmail_msg"></blockquote><div class=""><br class=""></div><div class="">Are all these strings guaranteed to be null terminated?  I see a lot of calling .data() </div></div></div></div></blockquote><br class=""></div><div>Since I’m converting from raw pointer, I assume that they were till now, otherwise it would have crashed? Maybe I missed something?</div><div><br class=""></div><div>— </div><div>Mehdi</div><br class=""></body></html>