aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheckImpl.h
diff options
context:
space:
mode:
authorVinayak Dev <104419489+vinayakdsci@users.noreply.github.com>2024-01-19 20:38:24 +0530
committerGitHub <noreply@github.com>2024-01-19 15:08:24 +0000
commit497a8604b39f8b5736c389f6d7ccd8242a122cbf (patch)
tree651e56057e7cd9552d5591d3dbe377a22a2dbd10 /llvm/lib/FileCheck/FileCheckImpl.h
parent9350860824a8badbbfe2ba81804e163543da2173 (diff)
downloadllvm-497a8604b39f8b5736c389f6d7ccd8242a122cbf.zip
llvm-497a8604b39f8b5736c389f6d7ccd8242a122cbf.tar.gz
llvm-497a8604b39f8b5736c389f6d7ccd8242a122cbf.tar.bz2
[FileCheck]: Fix diagnostics for NOT prefixes (#78412)
Fixes #70221 Fix a bug in FileCheck that corrects the error message when multiple prefixes are provided through --check-prefixes and one of them is a PREFIX-NOT. Earlier, only the first of the provided prefixes was displayed as the erroneous prefix, while the actual error might be on the prefix that occurred at the end of the prefix list in the input file. Now, the right NOT prefix is shown in the error message.
Diffstat (limited to 'llvm/lib/FileCheck/FileCheckImpl.h')
-rw-r--r--llvm/lib/FileCheck/FileCheckImpl.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h
index c154616..c772edd 100644
--- a/llvm/lib/FileCheck/FileCheckImpl.h
+++ b/llvm/lib/FileCheck/FileCheckImpl.h
@@ -823,9 +823,19 @@ struct FileCheckString {
/// The location in the match file that the check string was specified.
SMLoc Loc;
- /// All of the strings that are disallowed from occurring between this match
- /// string and the previous one (or start of file).
- std::vector<Pattern> DagNotStrings;
+ /// Hold the information about the DAG/NOT strings in the program, which are
+ /// not explicitly stored otherwise. This allows for better and more accurate
+ /// diagnostic messages.
+ struct DagNotPrefixInfo {
+ Pattern DagNotPat;
+ StringRef DagNotPrefix;
+
+ DagNotPrefixInfo(const Pattern &P, StringRef S)
+ : DagNotPat(P), DagNotPrefix(S) {}
+ };
+
+ /// Hold the DAG/NOT strings occurring in the input file.
+ std::vector<DagNotPrefixInfo> DagNotStrings;
FileCheckString(const Pattern &P, StringRef S, SMLoc L)
: Pat(P), Prefix(S), Loc(L) {}
@@ -845,12 +855,12 @@ struct FileCheckString {
/// \p Buffer. Errors are reported against \p SM and diagnostics recorded in
/// \p Diags according to the verbosity level set in \p Req.
bool CheckNot(const SourceMgr &SM, StringRef Buffer,
- const std::vector<const Pattern *> &NotStrings,
+ const std::vector<const DagNotPrefixInfo *> &NotStrings,
const FileCheckRequest &Req,
std::vector<FileCheckDiag> *Diags) const;
/// Matches "dag strings" and their mixed "not strings".
size_t CheckDag(const SourceMgr &SM, StringRef Buffer,
- std::vector<const Pattern *> &NotStrings,
+ std::vector<const DagNotPrefixInfo *> &NotStrings,
const FileCheckRequest &Req,
std::vector<FileCheckDiag> *Diags) const;
};