[llvm-objcopy] Tidy up error messages

This patch brings various error messages into line with each other, by
removing trailing full stops, and making the first letter lower-case.
This addresses https://bugs.llvm.org/show_bug.cgi?id=40859.

Reviewed by: jhenderson, rupprecht, jakehehrlich

Differential Revision: https://reviews.llvm.org/D62072

Patch by Alex Brachet

llvm-svn: 361384
diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
index 072e5f0..b14af2c 100644
--- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -168,7 +168,7 @@
       return std::move(Err);
   }
   return createStringError(llvm::errc::invalid_argument,
-                           "Could not find build ID.");
+                           "could not find build ID");
 }
 
 static Expected<ArrayRef<uint8_t>>
@@ -186,7 +186,7 @@
 }
 
 template <class... Ts>
-static Error makeStringError(std::error_code EC, const Twine &Msg, Ts&&... Args) {
+static Error makeStringError(std::error_code EC, const Twine &Msg, Ts &&... Args) {
   std::string FullMsg = (EC.message() + ": " + Msg).str();
   return createStringError(EC, FullMsg.c_str(), std::forward<Ts>(Args)...);
 }
@@ -222,16 +222,16 @@
                             /*MakeAbsolute*/ false);
   if (auto EC = sys::fs::create_hard_link(ToLink, TmpPath)) {
     Path.push_back('\0');
-    return makeStringError(EC, "cannot link %s to %s", ToLink.data(),
-                             Path.data());
+    return makeStringError(EC, "cannot link '%s' to '%s'", ToLink.data(),
+                           Path.data());
   }
   // We then atomically rename the link into place which will just move the
   // link. If rename fails something is more seriously wrong so just return
   // an error.
   if (auto EC = sys::fs::rename(TmpPath, Path)) {
     Path.push_back('\0');
-    return makeStringError(EC, "cannot link %s to %s", ToLink.data(),
-                             Path.data());
+    return makeStringError(EC, "cannot link '%s' to '%s'", ToLink.data(),
+                           Path.data());
   }
   // If `Path` was already a hard-link to the same underlying file then the
   // temp file will be left so we need to remove it. Remove will not cause
@@ -239,7 +239,7 @@
   // it rather than checking.
   if (auto EC = sys::fs::remove(TmpPath)) {
     TmpPath.push_back('\0');
-    return makeStringError(EC, "could not remove %s", TmpPath.data());
+    return makeStringError(EC, "could not remove '%s'", TmpPath.data());
   }
   return Error::success();
 }
@@ -250,7 +250,7 @@
   auto OnlyKeepDWOPred = [&DWOFile](const SectionBase &Sec) {
     return onlyKeepDWOPred(*DWOFile, Sec);
   };
-  if (Error E = DWOFile->removeSections(Config.AllowBrokenLinks,
+  if (Error E = DWOFile->removeSections(Config.AllowBrokenLinks, 
                                         OnlyKeepDWOPred))
     return E;
   if (Config.OutputArch) {
@@ -269,10 +269,9 @@
   for (auto &Sec : Obj.sections()) {
     if (Sec.Name == SecName) {
       if (Sec.OriginalData.empty())
-        return createStringError(
-            object_error::parse_failed,
-            "Can't dump section \"%s\": it has no contents",
-            SecName.str().c_str());
+        return createStringError(object_error::parse_failed,
+                                 "cannot dump section '%s': it has no contents",
+                                 SecName.str().c_str());
       Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
           FileOutputBuffer::create(Filename, Sec.OriginalData.size());
       if (!BufferOrErr)
@@ -285,7 +284,8 @@
       return Error::success();
     }
   }
-  return createStringError(object_error::parse_failed, "Section not found");
+  return createStringError(object_error::parse_failed, "section '%s' not found",
+                           SecName.str().c_str());
 }
 
 static bool isCompressable(const SectionBase &Section) {
@@ -534,11 +534,11 @@
   }
 
   if (Config.CompressionType != DebugCompressionType::None)
-    replaceDebugSections(Obj, RemovePred, isCompressable,
+    replaceDebugSections(Obj, RemovePred, isCompressable, 
                          [&Config, &Obj](const SectionBase *S) {
                            return &Obj.addSection<CompressedSection>(
-                               *S, Config.CompressionType);
-                         });
+                                *S, Config.CompressionType);
+                        });
   else if (Config.DecompressDebugSections)
     replaceDebugSections(
         Obj, RemovePred,
@@ -600,13 +600,13 @@
           Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str();
           PrefixedSections.insert(&Sec);
 
-        // Rename relocation sections associated to the allocated sections.
-        // For example, if we rename .text to .prefix.text, we also rename
-        // .rel.text to .rel.prefix.text.
-        //
-        // Dynamic relocation sections (SHT_REL[A] with SHF_ALLOC) are handled
-        // above, e.g., .rela.plt is renamed to .prefix.rela.plt, not
-        // .rela.prefix.plt since GNU objcopy does so.
+          // Rename relocation sections associated to the allocated sections.
+          // For example, if we rename .text to .prefix.text, we also rename
+          // .rel.text to .rel.prefix.text.
+          //
+          // Dynamic relocation sections (SHT_REL[A] with SHF_ALLOC) are handled
+          // above, e.g., .rela.plt is renamed to .prefix.rela.plt, not
+          // .rela.prefix.plt since GNU objcopy does so.
         } else if (auto *RelocSec = dyn_cast<RelocationSectionBase>(&Sec)) {
           auto *TargetSec = RelocSec->getSection();
           if (TargetSec && (TargetSec->Flags & SHF_ALLOC)) {
@@ -735,7 +735,7 @@
       return createFileError(
           Config.InputFilename,
           createStringError(object_error::parse_failed,
-                            "build ID is smaller than two bytes."));
+                            "build ID is smaller than two bytes"));
   }
 
   if (!Config.BuildIdLinkDir.empty() && Config.BuildIdLinkInput)