diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include using namespace llvm; @@ -1825,7 +1826,10 @@ // found. unsigned LineNumber = 1; - bool FoundUsedCheckPrefix = false; + StringSet<> PrefixesNotFound; + for (auto CP : Req.CheckPrefixes) + PrefixesNotFound.insert(CP); + while (1) { Check::FileCheckType CheckTy; @@ -1837,7 +1841,7 @@ if (UsedPrefix.empty()) break; if (CheckTy != Check::CheckComment) - FoundUsedCheckPrefix = true; + PrefixesNotFound.erase(UsedPrefix); assert(UsedPrefix.data() == Buffer.data() && "Failed to move Buffer's start forward, or pointed prefix outside " @@ -1930,14 +1934,16 @@ // When there are no used prefixes we report an error except in the case that // no prefix is specified explicitly but -implicit-check-not is specified. - if (!FoundUsedCheckPrefix && + if (!PrefixesNotFound.empty() && (ImplicitNegativeChecks.empty() || !Req.IsDefaultCheckPrefix)) { errs() << "error: no check strings found with prefix" << (Req.CheckPrefixes.size() > 1 ? "es " : " "); - for (size_t I = 0, E = Req.CheckPrefixes.size(); I != E; ++I) { - if (I != 0) + bool First = true; + for (auto P : PrefixesNotFound.keys()) { + if (!First) errs() << ", "; - errs() << "\'" << Req.CheckPrefixes[I] << ":'"; + errs() << "\'" << P << ":'"; + First = false; } errs() << '\n'; return true;