The attached patch was automatically generated by the example tool for
review in: 
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110523/042163.html
(contributed by Marcin, cc'ed).

This brought up a use of ConstantArray::get that was based on an older
implementation of the interface, but fixed by calling .c_str() after
appending a null-byte to a string and handing it to a StringRef. I
deleted the outdated comment on the implementation of get(), as the
comment in the header nicely explains the correct (and up-to-date)
behavior.

Cheers,
/Manuel
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 99d464f..594777b 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -3815,13 +3815,10 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string& BitMap) {
       BitMap += byte;
     }
   }
-  // null terminate string.
-  unsigned char zero = 0;
-  BitMap += zero;
   
   llvm::GlobalVariable * Entry =
   CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
-                    llvm::ConstantArray::get(VMContext, BitMap.c_str()),
+                    llvm::ConstantArray::get(VMContext, BitMap),
                     ((ObjCABI == 2) ?
                      "__TEXT,__objc_classname,cstring_literals" :
                      "__TEXT,__cstring,cstring_literals"),
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index 62fa1f9..fd47aec 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -309,7 +309,7 @@ void CodeGenAction::ExecuteAction() {
     // FIXME: This is stupid, IRReader shouldn't take ownership.
     llvm::MemoryBuffer *MainFileCopy =
       llvm::MemoryBuffer::getMemBufferCopy(MainFile->getBuffer(),
-                                           getCurrentFile().c_str());
+                                           getCurrentFile());
 
     llvm::SMDiagnostic Err;
     TheModule.reset(ParseIR(MainFileCopy, Err, *VMContext));
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index fe65054..8b222b8 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -1215,7 +1215,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
   if (!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) {
     std::string TmpName =
       GetTemporaryPath(types::getTypeTempSuffix(JA.getType()));
-    return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
+    return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
 
   llvm::SmallString<128> BasePath(BaseInput);
@@ -1241,7 +1241,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
     std::string Suffixed(BaseName.substr(0, End));
     Suffixed += '.';
     Suffixed += Suffix;
-    NamedOutput = C.getArgs().MakeArgString(Suffixed.c_str());
+    NamedOutput = C.getArgs().MakeArgString(Suffixed);
   }
 
   // As an annoying special case, PCH generation doesn't strip the pathname.
@@ -1352,7 +1352,7 @@ std::string Driver::GetTemporaryPath(const char *Suffix) const {
 
 const HostInfo *Driver::GetHostInfo(const char *TripleStr) const {
   llvm::PrettyStackTraceString CrashInfo("Constructing host");
-  llvm::Triple Triple(llvm::Triple::normalize(TripleStr).c_str());
+  llvm::Triple Triple(llvm::Triple::normalize(TripleStr));
 
   // TCE is an osless target
   if (Triple.getArchName() == "tce")
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 4e0d4c1..7eff714 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -573,7 +573,7 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
   if (CxxIncludeRoot != "") {
     llvm::StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
     if (CxxIncludeArch == "")
-      AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(),
+      AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str(),
                                   CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR,
                                   triple);
     else
diff --git a/lib/Frontend/TextDiagnosticBuffer.cpp b/lib/Frontend/TextDiagnosticBuffer.cpp
index 069c86d..028f0e5 100644
--- a/lib/Frontend/TextDiagnosticBuffer.cpp
+++ b/lib/Frontend/TextDiagnosticBuffer.cpp
@@ -43,9 +43,9 @@ void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
 void TextDiagnosticBuffer::FlushDiagnostics(Diagnostic &Diags) const {
   // FIXME: Flush the diagnostics in order.
   for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it)
-    Diags.Report(Diags.getCustomDiagID(Diagnostic::Error, it->second.c_str()));
+    Diags.Report(Diags.getCustomDiagID(Diagnostic::Error, it->second));
   for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
-    Diags.Report(Diags.getCustomDiagID(Diagnostic::Warning,it->second.c_str()));
+    Diags.Report(Diags.getCustomDiagID(Diagnostic::Warning,it->second));
   for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
-    Diags.Report(Diags.getCustomDiagID(Diagnostic::Note, it->second.c_str()));
+    Diags.Report(Diags.getCustomDiagID(Diagnostic::Note, it->second));
 }
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp
index d6e34ef..b1675ed 100644
--- a/lib/Rewrite/RewriteObjC.cpp
+++ b/lib/Rewrite/RewriteObjC.cpp
@@ -3661,12 +3661,12 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
       InstanceMethods.push_back(Setter);
   }
   RewriteObjCMethodsMetaData(InstanceMethods.begin(), InstanceMethods.end(),
-                             true, "CATEGORY_", FullCategoryName.c_str(),
+                             true, "CATEGORY_", FullCategoryName,
                              Result);
 
   // Build _objc_method_list for class's class methods if needed
   RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(),
-                             false, "CATEGORY_", FullCategoryName.c_str(),
+                             false, "CATEGORY_", FullCategoryName,
                              Result);
 
   // Protocols referenced in class declaration?
@@ -5359,7 +5359,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
 
   VarDecl *NewVD = VarDecl::Create(*Context, TUDecl,
                                    SourceLocation(), SourceLocation(),
-                                   &Context->Idents.get(DescData.c_str()),
+                                   &Context->Idents.get(DescData),
                                    Context->VoidPtrTy, 0,
                                    SC_Static, SC_None);
   UnaryOperator *DescRefExpr =
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 0ab1704..2f5110f 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1300,7 +1300,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(unsigned ID) {
       std::string ErrorStr = "could not find file '";
       ErrorStr += Filename;
       ErrorStr += "' referenced by AST file";
-      Error(ErrorStr.c_str());
+      Error(ErrorStr);
       return Failure;
     }
 
@@ -2505,7 +2505,7 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(llvm::StringRef FileName,
     } else
       F.Buffer.reset(FileMgr.getBufferForFile(FileName, &ErrStr));
     if (!F.Buffer) {
-      Error(ErrStr.c_str());
+      Error(ErrStr);
       return IgnorePCH;
     }
   }
diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp
index 9cc92f1..a16cb6e 100644
--- a/lib/Tooling/Tooling.cpp
+++ b/lib/Tooling/Tooling.cpp
@@ -237,8 +237,8 @@ bool RunToolWithFlagsOnCode(
        It != End; ++It) {
     // Inject the code as the given file name into the preprocessor options.
     const llvm::MemoryBuffer* Input =
-        llvm::MemoryBuffer::getMemBuffer(It->second.c_str());
-    Invocation->getPreprocessorOpts().addRemappedFile(It->first.c_str(), Input);
+        llvm::MemoryBuffer::getMemBuffer(It->second);
+    Invocation->getPreprocessorOpts().addRemappedFile(It->first, Input);
   }
 
   return RunInvocation(BinaryName, Compilation.get(),
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to