[PATCH] D14356: Sancov in C++.

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 15:29:54 PST 2015


kcc added a comment.

more to follow


================
Comment at: lib/sanitizer_common/sancov.cc:44
@@ +43,3 @@
+    cl::values(clEnumValN(PrintAction, "print", "Print coverage addresses"),
+               clEnumValN(CoveredFunctionsAction, "coveredfns",
+                          "Print all covered funcions."),
----------------
use full words, please, e.g. covered_functions

================
Comment at: lib/sanitizer_common/sancov.cc:96
@@ +95,3 @@
+static std::string demangle(std::string Name) {
+  if (Name.substr(0, 2) != "_Z") {
+    return Name;
----------------
no {} in such code. 

================
Comment at: lib/sanitizer_common/sancov.cc:154
@@ +153,3 @@
+    std::unique_ptr<std::vector<uint64_t>> Addrs(new std::vector<uint64_t>());
+    int Sz = std::accumulate(
+        Covs.begin(), Covs.end(), 0,
----------------
size_t? 

================
Comment at: lib/sanitizer_common/sancov.cc:156
@@ +155,3 @@
+        Covs.begin(), Covs.end(), 0,
+        [](const int &A, const std::unique_ptr<CoverageData> &B) {
+          return A + B->Addrs->size();
----------------
<optional> I am not a huge fan of lambda functions when they don't save code or make it more readable. 
Will it not be shorter *and* simpler to write regular loop here? </optional>

================
Comment at: lib/sanitizer_common/sancov.cc:163
@@ +162,3 @@
+    }
+    std::sort(Addrs->begin(), Addrs->end());
+    Addrs->erase(std::unique(Addrs->begin(), Addrs->end()), Addrs->end());
----------------
won't it be simpler to insert everything into a set, and they copy into a vector? 


http://reviews.llvm.org/D14356





More information about the llvm-commits mailing list