[llvm] r244134 - Replace &vector[0] with vector.data() to avoid invalid dereference caught by debug STL. Also move a '*' for consistency and fix an 80-col violation.

Nick Lewycky nicholas at mxc.ca
Wed Aug 5 14:16:02 PDT 2015


Author: nicholas
Date: Wed Aug  5 16:16:02 2015
New Revision: 244134

URL: http://llvm.org/viewvc/llvm-project?rev=244134&view=rev
Log:
Replace &vector[0] with vector.data() to avoid invalid dereference caught by debug STL. Also move a '*' for consistency and fix an 80-col violation.

Modified:
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=244134&r1=244133&r2=244134&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Wed Aug  5 16:16:02 2015
@@ -103,7 +103,7 @@ namespace options {
   // use only and will not be passed.
   static std::vector<const char *> extra;
 
-  static void process_plugin_option(const char* opt_)
+  static void process_plugin_option(const char *opt_)
   {
     if (opt_ == nullptr)
       return;
@@ -322,7 +322,8 @@ static ld_plugin_status claim_file_hook(
       message(LDPL_ERROR, "Failed to get a view of %s", file->name);
       return LDPS_ERR;
     }
-    BufferRef = MemoryBufferRef(StringRef((const char *)view, file->filesize), "");
+    BufferRef =
+        MemoryBufferRef(StringRef((const char *)view, file->filesize), "");
   } else {
     int64_t offset = 0;
     // Gold has found what might be IR part-way inside of a file, such as
@@ -429,7 +430,7 @@ static ld_plugin_status claim_file_hook(
   }
 
   if (!cf.syms.empty()) {
-    if (add_symbols(cf.handle, cf.syms.size(), &cf.syms[0]) != LDPS_OK) {
+    if (add_symbols(cf.handle, cf.syms.size(), cf.syms.data()) != LDPS_OK) {
       message(LDPL_ERROR, "Unable to add symbols!");
       return LDPS_ERR;
     }
@@ -583,7 +584,7 @@ getModuleForFile(LLVMContext &Context, c
                  ld_plugin_input_file &Info, raw_fd_ostream *ApiFile,
                  StringSet<> &Internalize, StringSet<> &Maybe) {
 
-  if (get_symbols(F.handle, F.syms.size(), &F.syms[0]) != LDPS_OK)
+  if (get_symbols(F.handle, F.syms.size(), F.syms.data()) != LDPS_OK)
     message(LDPL_FATAL, "Failed to get symbol information");
 
   const void *View;




More information about the llvm-commits mailing list