From ede28b79ea82ff9b220451c0d3409cdb9b28fa1d Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Fri, 26 Feb 2016 23:34:02 +0000 Subject: [FileCheck] Abort if -NOT is combined with another suffix. Combinations of suffixes that look useful actually are ignored; complaining about them will avoid mistakes. Differential Revision: http://reviews.llvm.org/D17587 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262092 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/FileCheck/FileCheck.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'utils/FileCheck') diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 593ea9f441b..69f93020317 100644 --- a/utils/FileCheck/FileCheck.cpp +++ b/utils/FileCheck/FileCheck.cpp @@ -86,7 +86,9 @@ namespace Check { /// MatchEOF - When set, this pattern only matches the end of file. This is /// used for trailing CHECK-NOTs. - CheckEOF + CheckEOF, + /// CheckBadNot - Found -NOT combined with another CHECK suffix. + CheckBadNot }; } @@ -693,6 +695,7 @@ static bool IsPartOfWord(char c) { static size_t CheckTypeSize(Check::CheckType Ty) { switch (Ty) { case Check::CheckNone: + case Check::CheckBadNot: return 0; case Check::CheckPlain: @@ -746,6 +749,12 @@ static Check::CheckType FindCheckType(StringRef Buffer, StringRef Prefix) { if (Rest.startswith("LABEL:")) return Check::CheckLabel; + // You can't combine -NOT with another suffix. + if (Rest.startswith("DAG-NOT:") || Rest.startswith("NOT-DAG:") || + Rest.startswith("NEXT-NOT:") || Rest.startswith("NOT-NEXT:") || + Rest.startswith("SAME-NOT:") || Rest.startswith("NOT-SAME:")) + return Check::CheckBadNot; + return Check::CheckNone; } @@ -914,6 +923,14 @@ static bool ReadCheckFile(SourceMgr &SM, // PrefixLoc is to the start of the prefix. Skip to the end. Buffer = Buffer.drop_front(UsedPrefix.size() + CheckTypeSize(CheckTy)); + // Complain about useful-looking but unsupported suffixes. + if (CheckTy == Check::CheckBadNot) { + SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), + SourceMgr::DK_Error, + "unsupported -NOT combo on prefix '" + UsedPrefix + "'"); + return true; + } + // Okay, we found the prefix, yay. Remember the rest of the line, but ignore // leading and trailing whitespace. Buffer = Buffer.substr(Buffer.find_first_not_of(" \t")); -- cgit v1.2.3