[PATCH] D149791: [clang][deps] NFC: Replace a vector with an array

David Stone via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 3 15:10:15 PDT 2023


davidstone created this revision.
Herald added a project: All.
davidstone requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`ResourceDirectoryCache::findResourceDir` uses a `std::vector` when a `std::array` would do. Make this replacement and declare the variable `const`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149791

Files:
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===================================================================
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -252,11 +252,9 @@
     if (CachedResourceDir != Cache.end())
       return CachedResourceDir->second;
 
-    std::vector<StringRef> PrintResourceDirArgs{ClangBinaryName};
-    if (ClangCLMode)
-      PrintResourceDirArgs.push_back("/clang:-print-resource-dir");
-    else
-      PrintResourceDirArgs.push_back("-print-resource-dir");
+    const std::array<StringRef, 2> PrintResourceDirArgs{
+        ClangBinaryName,
+        ClangCLMode ? "/clang:-print-resource-dir" : "-print-resource-dir"};
 
     llvm::SmallString<64> OutputFile, ErrorFile;
     llvm::sys::fs::createTemporaryFile("print-resource-dir-output",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149791.519274.patch
Type: text/x-patch
Size: 841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230503/e6285ca2/attachment.bin>


More information about the cfe-commits mailing list