From 9409e5c04f0a534b53ce2f0e0a81c5e7e70c38f1 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Tue, 17 May 2022 12:54:39 -0400
Subject: clang-tidy: address `readability-container-data-pointer` lints

---
 Source/CTest/cmCTestBZR.cxx           | 14 +++++++-------
 Source/CTest/cmCTestCVS.cxx           |  4 ++--
 Source/CTest/cmCTestGIT.cxx           |  4 ++--
 Source/CTest/cmCTestHG.cxx            | 10 +++++-----
 Source/CTest/cmCTestP4.cxx            | 14 +++++++-------
 Source/CTest/cmCTestSVN.cxx           | 12 ++++++------
 Source/CTest/cmCTestSubmitHandler.cxx |  2 +-
 Source/CTest/cmCTestVC.cxx            |  2 +-
 Source/cmCTest.cxx                    | 16 ++++++++--------
 Source/cmCryptoHash.cxx               |  2 +-
 Source/cmSystemTools.cxx              | 10 +++++-----
 Source/cmUuid.cxx                     | 10 +++++-----
 12 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index eb8ee0a..81a866a 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -254,26 +254,26 @@ private:
       this->BZR->DoRevision(this->Rev, this->Changes);
     } else if (!this->CData.empty() &&
                (name == "file" || name == "directory")) {
-      this->CurChange.Path.assign(&this->CData[0], this->CData.size());
+      this->CurChange.Path.assign(this->CData.data(), this->CData.size());
       cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
       this->Changes.push_back(this->CurChange);
     } else if (!this->CData.empty() && name == "symlink") {
       // symlinks have an arobase at the end in the log
-      this->CurChange.Path.assign(&this->CData[0], this->CData.size() - 1);
+      this->CurChange.Path.assign(this->CData.data(), this->CData.size() - 1);
       cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
       this->Changes.push_back(this->CurChange);
     } else if (!this->CData.empty() && name == "committer") {
-      this->Rev.Author.assign(&this->CData[0], this->CData.size());
+      this->Rev.Author.assign(this->CData.data(), this->CData.size());
       if (this->EmailRegex.find(this->Rev.Author)) {
         this->Rev.Author = this->EmailRegex.match(1);
         this->Rev.EMail = this->EmailRegex.match(2);
       }
     } else if (!this->CData.empty() && name == "timestamp") {
-      this->Rev.Date.assign(&this->CData[0], this->CData.size());
+      this->Rev.Date.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "message") {
-      this->Rev.Log.assign(&this->CData[0], this->CData.size());
+      this->Rev.Log.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "revno") {
-      this->Rev.Rev.assign(&this->CData[0], this->CData.size());
+      this->Rev.Rev.assign(this->CData.data(), this->CData.size());
     }
     this->CData.clear();
   }
@@ -388,7 +388,7 @@ bool cmCTestBZR::UpdateImpl()
   // For some reason bzr uses stderr to display the update status.
   OutputLogger out(this->Log, "pull-out> ");
   UpdateParser err(this, "pull-err> ");
-  return this->RunUpdateCommand(&bzr_update[0], &out, &err);
+  return this->RunUpdateCommand(bzr_update.data(), &out, &err);
 }
 
 bool cmCTestBZR::LoadRevisions()
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 8f5542e..87ab762 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -101,7 +101,7 @@ bool cmCTestCVS::UpdateImpl()
 
   UpdateParser out(this, "up-out> ");
   UpdateParser err(this, "up-err> ");
-  return this->RunUpdateCommand(&cvs_update[0], &out, &err);
+  return this->RunUpdateCommand(cvs_update.data(), &out, &err);
 }
 
 class cmCTestCVS::LogParser : public cmCTestVC::LineParser
@@ -258,7 +258,7 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
     revisions.resize(2, this->Unknown);
 
     // Write the entry for this file with these revisions.
-    File f(fi.second, &revisions[0], &revisions[1]);
+    File f(fi.second, revisions.data(), revisions.data() + 1);
     this->WriteXMLEntry(xml, path, fi.first, full, f);
   }
   xml.EndElement(); // Directory
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index a55f3e8..0b09f47 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -176,7 +176,7 @@ bool cmCTestGIT::UpdateByFetchAndReset()
   // Fetch upstream refs.
   OutputLogger fetch_out(this->Log, "fetch-out> ");
   OutputLogger fetch_err(this->Log, "fetch-err> ");
-  if (!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err)) {
+  if (!this->RunUpdateCommand(git_fetch.data(), &fetch_out, &fetch_err)) {
     return false;
   }
 
@@ -225,7 +225,7 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
 
   OutputLogger custom_out(this->Log, "custom-out> ");
   OutputLogger custom_err(this->Log, "custom-err> ");
-  return this->RunUpdateCommand(&git_custom[0], &custom_out, &custom_err);
+  return this->RunUpdateCommand(git_custom.data(), &custom_out, &custom_err);
 }
 
 bool cmCTestGIT::UpdateInternal()
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 5f4581e..97b01ba 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -157,7 +157,7 @@ bool cmCTestHG::UpdateImpl()
 
   OutputLogger out(this->Log, "update-out> ");
   OutputLogger err(this->Log, "update-err> ");
-  return this->RunUpdateCommand(&hg_update[0], &out, &err);
+  return this->RunUpdateCommand(hg_update.data(), &out, &err);
 }
 
 class cmCTestHG::LogParser
@@ -213,13 +213,13 @@ private:
     if (name == "logentry") {
       this->HG->DoRevision(this->Rev, this->Changes);
     } else if (!this->CData.empty() && name == "author") {
-      this->Rev.Author.assign(&this->CData[0], this->CData.size());
+      this->Rev.Author.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "email") {
-      this->Rev.EMail.assign(&this->CData[0], this->CData.size());
+      this->Rev.EMail.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "date") {
-      this->Rev.Date.assign(&this->CData[0], this->CData.size());
+      this->Rev.Date.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "msg") {
-      this->Rev.Log.assign(&this->CData[0], this->CData.size());
+      this->Rev.Log.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "files") {
       std::vector<std::string> paths = this->SplitCData();
       for (std::string const& path : paths) {
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 2a7c3ad..ce8b7c7 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -160,7 +160,7 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
 
     UserParser out(this, "users-out> ");
     OutputLogger err(this->Log, "users-err> ");
-    this->RunChild(&p4_users[0], &out, &err);
+    this->RunChild(p4_users.data(), &out, &err);
 
     // The user should now be added to the map. Search again.
     it = this->Users.find(username);
@@ -352,7 +352,7 @@ std::string cmCTestP4::GetWorkingRevision()
   IdentifyParser out(this, "p4_changes-out> ", rev);
   OutputLogger err(this->Log, "p4_changes-err> ");
 
-  bool result = this->RunChild(&p4_identify[0], &out, &err);
+  bool result = this->RunChild(p4_identify.data(), &out, &err);
 
   // If there was a problem contacting the server return "<unknown>"
   if (!result) {
@@ -416,7 +416,7 @@ bool cmCTestP4::LoadRevisions()
   OutputLogger err(this->Log, "p4_changes-err> ");
 
   this->ChangeLists.clear();
-  this->RunChild(&p4_changes[0], &out, &err);
+  this->RunChild(p4_changes.data(), &out, &err);
 
   if (this->ChangeLists.empty()) {
     return true;
@@ -433,7 +433,7 @@ bool cmCTestP4::LoadRevisions()
 
     DescribeParser outDescribe(this, "p4_describe-out> ");
     OutputLogger errDescribe(this->Log, "p4_describe-err> ");
-    this->RunChild(&p4_describe[0], &outDescribe, &errDescribe);
+    this->RunChild(p4_describe.data(), &outDescribe, &errDescribe);
   }
   return true;
 }
@@ -453,7 +453,7 @@ bool cmCTestP4::LoadModifications()
 
   DiffParser out(this, "p4_diff-out> ");
   OutputLogger err(this->Log, "p4_diff-err> ");
-  this->RunChild(&p4_diff[0], &out, &err);
+  this->RunChild(p4_diff.data(), &out, &err);
   return true;
 }
 
@@ -471,7 +471,7 @@ bool cmCTestP4::UpdateCustom(const std::string& custom)
   OutputLogger custom_out(this->Log, "p4_customsync-out> ");
   OutputLogger custom_err(this->Log, "p4_customsync-err> ");
 
-  return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err);
+  return this->RunUpdateCommand(p4_custom.data(), &custom_out, &custom_err);
 }
 
 bool cmCTestP4::UpdateImpl()
@@ -521,5 +521,5 @@ bool cmCTestP4::UpdateImpl()
   OutputLogger out(this->Log, "p4_sync-out> ");
   OutputLogger err(this->Log, "p4_sync-err> ");
 
-  return this->RunUpdateCommand(&p4_sync[0], &out, &err);
+  return this->RunUpdateCommand(p4_sync.data(), &out, &err);
 }
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 4692dbd..4c98fdf 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -286,9 +286,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
   args.push_back(nullptr);
 
   if (strcmp(parameters[0], "update") == 0) {
-    return this->RunUpdateCommand(&args[0], out, err);
+    return this->RunUpdateCommand(args.data(), out, err);
   }
-  return this->RunChild(&args[0], out, err);
+  return this->RunChild(args.data(), out, err);
 }
 
 class cmCTestSVN::LogParser
@@ -353,16 +353,16 @@ private:
     if (name == "logentry") {
       this->SVN->DoRevisionSVN(this->Rev, this->Changes);
     } else if (!this->CData.empty() && name == "path") {
-      std::string orig_path(&this->CData[0], this->CData.size());
+      std::string orig_path(this->CData.data(), this->CData.size());
       std::string new_path = this->SVNRepo.BuildLocalPath(orig_path);
       this->CurChange.Path.assign(new_path);
       this->Changes.push_back(this->CurChange);
     } else if (!this->CData.empty() && name == "author") {
-      this->Rev.Author.assign(&this->CData[0], this->CData.size());
+      this->Rev.Author.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "date") {
-      this->Rev.Date.assign(&this->CData[0], this->CData.size());
+      this->Rev.Date.assign(this->CData.data(), this->CData.size());
     } else if (!this->CData.empty() && name == "msg") {
-      this->Rev.Log.assign(&this->CData[0], this->CData.size());
+      this->Rev.Log.assign(this->CData.data(), this->CData.size());
     }
     this->CData.clear();
   }
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index a8e0652..e5b18f4 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -56,7 +56,7 @@ private:
   {
     std::string val;
     if (!this->CurrentValue.empty()) {
-      val.assign(&this->CurrentValue[0], this->CurrentValue.size());
+      val.assign(this->CurrentValue.data(), this->CurrentValue.size());
     }
     return val;
   }
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index d5711c5..609ccba 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -66,7 +66,7 @@ bool cmCTestVC::InitialCheckout(const std::string& command)
   this->Log << "--- Begin Initial Checkout ---\n";
   OutputLogger out(this->Log, "co-out> ");
   OutputLogger err(this->Log, "co-err> ");
-  bool result = this->RunChild(&vc_co[0], &out, &err, parent.c_str());
+  bool result = this->RunChild(vc_co.data(), &out, &err, parent.c_str());
   this->Log << "--- End Initial Checkout ---\n";
   if (!result) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 710b4d7..3673dfb 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1672,16 +1672,16 @@ std::string cmCTest::Base64EncodeFile(std::string const& file)
 #endif
   );
   std::vector<char> file_buffer(len + 1);
-  ifs.read(&file_buffer[0], len);
+  ifs.read(file_buffer.data(), len);
   ifs.close();
 
   std::vector<char> encoded_buffer((len * 3) / 2 + 5);
 
   size_t const rlen = cmsysBase64_Encode(
-    reinterpret_cast<unsigned char*>(&file_buffer[0]), len,
-    reinterpret_cast<unsigned char*>(&encoded_buffer[0]), 1);
+    reinterpret_cast<unsigned char*>(file_buffer.data()), len,
+    reinterpret_cast<unsigned char*>(encoded_buffer.data()), 1);
 
-  return std::string(&encoded_buffer[0], rlen);
+  return std::string(encoded_buffer.data(), rlen);
 }
 
 bool cmCTest::SubmitExtraFiles(std::vector<std::string> const& files)
@@ -3729,7 +3729,7 @@ bool cmCTest::CompressString(std::string& str)
   strm.avail_in = static_cast<uInt>(str.size());
   strm.next_in = in;
   strm.avail_out = outSize;
-  strm.next_out = &out[0];
+  strm.next_out = out.data();
   ret = deflate(&strm, Z_FINISH);
 
   if (ret != Z_STREAM_END) {
@@ -3743,10 +3743,10 @@ bool cmCTest::CompressString(std::string& str)
   // Now base64 encode the resulting binary string
   std::vector<unsigned char> base64EncodedBuffer((outSize * 3) / 2);
 
-  size_t rlen =
-    cmsysBase64_Encode(&out[0], strm.total_out, &base64EncodedBuffer[0], 1);
+  size_t rlen = cmsysBase64_Encode(out.data(), strm.total_out,
+                                   base64EncodedBuffer.data(), 1);
 
-  str.assign(reinterpret_cast<char*>(&base64EncodedBuffer[0]), rlen);
+  str.assign(reinterpret_cast<char*>(base64EncodedBuffer.data()), rlen);
 
   return true;
 }
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index b331862..9f369b9 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -182,7 +182,7 @@ void cmCryptoHash::Append(cm::string_view input)
 std::vector<unsigned char> cmCryptoHash::Finalize()
 {
   std::vector<unsigned char> hash(rhash_get_digest_size(this->Id), 0);
-  rhash_final(this->CTX, &hash[0]);
+  rhash_final(this->CTX, hash.data());
   return hash;
 }
 
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 527175d..512a5fa 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1995,7 +1995,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
           --length;
         }
         if (length > 0) {
-          line.append(&out[0], length);
+          line.append(out.data(), length);
         }
         out.erase(out.begin(), outiter + 1);
         return cmsysProcess_Pipe_STDOUT;
@@ -2013,7 +2013,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
           --length;
         }
         if (length > 0) {
-          line.append(&err[0], length);
+          line.append(err.data(), length);
         }
         err.erase(err.begin(), erriter + 1);
         return cmsysProcess_Pipe_STDERR;
@@ -2057,12 +2057,12 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
         erriter = err.begin() + size;
       }
       if (!out.empty()) {
-        line.append(&out[0], outiter - out.begin());
+        line.append(out.data(), outiter - out.begin());
         out.erase(out.begin(), out.end());
         return cmsysProcess_Pipe_STDOUT;
       }
       if (!err.empty()) {
-        line.append(&err[0], erriter - err.begin());
+        line.append(err.data(), erriter - err.begin());
         err.erase(err.begin(), err.end());
         return cmsysProcess_Pipe_STDERR;
       }
@@ -3149,7 +3149,7 @@ static cm::optional<bool> RemoveRPathELF(std::string const& file,
     }
     return false;
   }
-  if (!f.write(&bytes[0], bytes.size())) {
+  if (!f.write(bytes.data(), bytes.size())) {
     if (emsg) {
       *emsg = "Error replacing DYNAMIC table header.";
     }
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index 2513303..dc018b1 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -17,10 +17,10 @@ std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace,
 
   cmCryptoHash md5(cmCryptoHash::AlgoMD5);
   md5.Initialize();
-  md5.Append(&hashInput[0], hashInput.size());
+  md5.Append(hashInput.data(), hashInput.size());
   std::vector<unsigned char> digest = md5.Finalize();
 
-  return this->FromDigest(&digest[0], 3);
+  return this->FromDigest(digest.data(), 3);
 }
 
 std::string cmUuid::FromSha1(std::vector<unsigned char> const& uuidNamespace,
@@ -31,10 +31,10 @@ std::string cmUuid::FromSha1(std::vector<unsigned char> const& uuidNamespace,
 
   cmCryptoHash sha1(cmCryptoHash::AlgoSHA1);
   sha1.Initialize();
-  sha1.Append(&hashInput[0], hashInput.size());
+  sha1.Append(hashInput.data(), hashInput.size());
   std::vector<unsigned char> digest = sha1.Finalize();
 
-  return this->FromDigest(&digest[0], 5);
+  return this->FromDigest(digest.data(), 5);
 }
 
 void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace,
@@ -46,7 +46,7 @@ void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace,
   if (!name.empty()) {
     output.resize(output.size() + name.size());
 
-    memcpy(&output[0] + uuidNamespace.size(), name.c_str(), name.size());
+    memcpy(output.data() + uuidNamespace.size(), name.c_str(), name.size());
   }
 }
 
-- 
cgit v0.12