[PATCH] D42375: Add --print-icf flag

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 10:35:13 PST 2018


ruiu added inline comments.


================
Comment at: ELF/ICF.cpp:427
 
+  auto PrintICF = [&](const Twine &Prefix, size_t I) {
+    if (!Config->Verbose && !Config->PrintIcfSections)
----------------
Everything in this file is related to ICF, so "ICF" is redundant unless it is in the global namespace. I'd name this just `Print`.


================
Comment at: ELF/ICF.cpp:430
+      return;
+    const auto *F = Sections[I]->File;
+    std::string S = Prefix.str() + " section '" + Sections[I]->Name.str() +
----------------
Please avoid `auto` unless the actual type is obvious.

Maybe this code is a bit better.

  std::string Filename = Sections[I]->File ? Sections[I]->File->getName() : "<internal>";


================
Comment at: ELF/ICF.cpp:431-433
+    std::string S = Prefix.str() + " section '" + Sections[I]->Name.str() +
+                    "' from file '" + (F ? F->getName().str() : "<internal>") +
+                    "'";
----------------
I believe you can do this (which creates a Twine and call its str() function).

  std::string S = (Prefix + " section '" + Sections[I]->Name +
                    "' from file '" + (F ? F->getName() : "<internal>") +
                    "'").str();


https://reviews.llvm.org/D42375





More information about the llvm-commits mailing list