diff options
author | Mike Aizatsky <aizatsky@chromium.org> | 2017-03-03 18:22:20 +0000 |
---|---|---|
committer | Mike Aizatsky <aizatsky@chromium.org> | 2017-03-03 18:22:20 +0000 |
commit | fe2b115a25ce094b7bb080ebdff7604f7511aea5 (patch) | |
tree | cc0a0b4d8fa923269dce92edb694dbfc4ed135ad /tools/sancov | |
parent | d19fe96ac9cdf42b24f19a6175dddb7284516d2b (diff) |
[sancov] better input parameters validation
Differential Revision: https://reviews.llvm.org/D30370
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296900 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/sancov')
-rw-r--r-- | tools/sancov/sancov.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/sancov/sancov.cc b/tools/sancov/sancov.cc index cb097436bfe..7f103ebb904 100644 --- a/tools/sancov/sancov.cc +++ b/tools/sancov/sancov.cc @@ -180,7 +180,7 @@ struct CoverageStats { // --------- ERROR HANDLING --------- static void fail(const llvm::Twine &E) { - errs() << "Error: " << E << "\n"; + errs() << "ERROR: " << E << "\n"; exit(1); } @@ -192,7 +192,7 @@ static void failIf(bool B, const llvm::Twine &E) { static void failIfError(std::error_code Error) { if (!Error) return; - errs() << "Error: " << Error.message() << "(" << Error.value() << ")\n"; + errs() << "ERROR: " << Error.message() << "(" << Error.value() << ")\n"; exit(1); } @@ -202,7 +202,7 @@ template <typename T> static void failIfError(const ErrorOr<T> &E) { static void failIfError(Error Err) { if (Err) { - logAllUnhandledErrors(std::move(Err), errs(), "Error: "); + logAllUnhandledErrors(std::move(Err), errs(), "ERROR: "); exit(1); } } @@ -1086,6 +1086,9 @@ static void readAndPrintRawCoverage(const std::vector<std::string> &FileNames, static std::unique_ptr<SymbolizedCoverage> merge(const std::vector<std::unique_ptr<SymbolizedCoverage>> &Coverages) { + if (Coverages.empty()) + return nullptr; + auto Result = make_unique<SymbolizedCoverage>(); for (size_t I = 0; I < Coverages.size(); ++I) { @@ -1168,11 +1171,17 @@ readSymbolizeAndMergeCmdArguments(std::vector<std::string> FileNames) { CoverageByObjFile[Iter->second].push_back(FileName); }; + for (const auto &Pair : ObjFiles) { + auto FileName = Pair.second; + if (CoverageByObjFile.find(FileName) == CoverageByObjFile.end()) + errs() << "WARNING: No coverage file for " << FileName << "\n"; + } + // Read raw coverage and symbolize it. for (const auto &Pair : CoverageByObjFile) { if (findSanitizerCovFunctions(Pair.first).empty()) { errs() - << "Ignoring " << Pair.first + << "WARNING: Ignoring " << Pair.first << " and its coverage because __sanitizer_cov* functions were not " "found.\n"; continue; |