@@ -1784,7 +1784,7 @@ bool FileCheck::readCheckFile(
1784
1784
1785
1785
PatternContext->createLineVariable ();
1786
1786
1787
- std::vector<Pattern > ImplicitNegativeChecks;
1787
+ std::vector<FileCheckString::DagNotPrefixInfo > ImplicitNegativeChecks;
1788
1788
for (StringRef PatternString : Req.ImplicitCheckNot ) {
1789
1789
// Create a buffer with fake command line content in order to display the
1790
1790
// command line option responsible for the specific implicit CHECK-NOT.
@@ -1807,14 +1807,15 @@ bool FileCheck::readCheckFile(
1807
1807
}
1808
1808
}
1809
1809
1810
- ImplicitNegativeChecks.push_back (
1811
- Pattern (Check::CheckNot, PatternContext.get ()));
1812
- ImplicitNegativeChecks.back ().parsePattern (PatternInBuffer,
1813
- " IMPLICIT-CHECK" , SM, Req);
1810
+ ImplicitNegativeChecks.emplace_back (
1811
+ Pattern (Check::CheckNot, PatternContext.get ()),
1812
+ StringRef (" IMPLICIT-CHECK" ));
1813
+ ImplicitNegativeChecks.back ().DagNotPat .parsePattern (
1814
+ PatternInBuffer, " IMPLICIT-CHECK" , SM, Req);
1814
1815
}
1815
1816
1816
- std::vector<Pattern > DagNotMatches = ImplicitNegativeChecks;
1817
-
1817
+ std::vector<FileCheckString::DagNotPrefixInfo > DagNotMatches =
1818
+ ImplicitNegativeChecks;
1818
1819
// LineNumber keeps track of the line on which CheckPrefix instances are
1819
1820
// found.
1820
1821
unsigned LineNumber = 1 ;
@@ -1926,7 +1927,7 @@ bool FileCheck::readCheckFile(
1926
1927
1927
1928
// Handle CHECK-DAG/-NOT.
1928
1929
if (CheckTy == Check::CheckDAG || CheckTy == Check::CheckNot) {
1929
- DagNotMatches.push_back (P );
1930
+ DagNotMatches.emplace_back (P, UsedPrefix );
1930
1931
continue ;
1931
1932
}
1932
1933
@@ -2165,7 +2166,7 @@ size_t FileCheckString::Check(const SourceMgr &SM, StringRef Buffer,
2165
2166
FileCheckRequest &Req,
2166
2167
std::vector<FileCheckDiag> *Diags) const {
2167
2168
size_t LastPos = 0 ;
2168
- std::vector<const Pattern *> NotStrings;
2169
+ std::vector<const DagNotPrefixInfo *> NotStrings;
2169
2170
2170
2171
// IsLabelScanMode is true when we are scanning forward to find CHECK-LABEL
2171
2172
// bounds; we have not processed variable definitions within the bounded block
@@ -2302,17 +2303,19 @@ bool FileCheckString::CheckSame(const SourceMgr &SM, StringRef Buffer) const {
2302
2303
return false ;
2303
2304
}
2304
2305
2305
- bool FileCheckString::CheckNot (const SourceMgr &SM, StringRef Buffer,
2306
- const std::vector< const Pattern *> &NotStrings ,
2307
- const FileCheckRequest &Req ,
2308
- std::vector<FileCheckDiag> *Diags) const {
2306
+ bool FileCheckString::CheckNot (
2307
+ const SourceMgr &SM, StringRef Buffer ,
2308
+ const std::vector< const DagNotPrefixInfo *> &NotStrings ,
2309
+ const FileCheckRequest &Req, std::vector<FileCheckDiag> *Diags) const {
2309
2310
bool DirectiveFail = false ;
2310
- for (const Pattern *Pat : NotStrings) {
2311
- assert ((Pat->getCheckTy () == Check::CheckNot) && " Expect CHECK-NOT!" );
2312
- Pattern::MatchResult MatchResult = Pat->match (Buffer, SM);
2313
- if (Error Err = reportMatchResult (/* ExpectedMatch=*/ false , SM, Prefix,
2314
- Pat->getLoc (), *Pat, 1 , Buffer,
2315
- std::move (MatchResult), Req, Diags)) {
2311
+ for (auto NotInfo : NotStrings) {
2312
+ assert ((NotInfo->DagNotPat .getCheckTy () == Check::CheckNot) &&
2313
+ " Expect CHECK-NOT!" );
2314
+ Pattern::MatchResult MatchResult = NotInfo->DagNotPat .match (Buffer, SM);
2315
+ if (Error Err = reportMatchResult (
2316
+ /* ExpectedMatch=*/ false , SM, NotInfo->DagNotPrefix ,
2317
+ NotInfo->DagNotPat .getLoc (), NotInfo->DagNotPat , 1 , Buffer,
2318
+ std::move (MatchResult), Req, Diags)) {
2316
2319
cantFail (handleErrors (std::move (Err), [&](const ErrorReported &E) {}));
2317
2320
DirectiveFail = true ;
2318
2321
continue ;
@@ -2321,10 +2324,11 @@ bool FileCheckString::CheckNot(const SourceMgr &SM, StringRef Buffer,
2321
2324
return DirectiveFail;
2322
2325
}
2323
2326
2324
- size_t FileCheckString::CheckDag (const SourceMgr &SM, StringRef Buffer,
2325
- std::vector<const Pattern *> &NotStrings,
2326
- const FileCheckRequest &Req,
2327
- std::vector<FileCheckDiag> *Diags) const {
2327
+ size_t
2328
+ FileCheckString::CheckDag (const SourceMgr &SM, StringRef Buffer,
2329
+ std::vector<const DagNotPrefixInfo *> &NotStrings,
2330
+ const FileCheckRequest &Req,
2331
+ std::vector<FileCheckDiag> *Diags) const {
2328
2332
if (DagNotStrings.empty ())
2329
2333
return 0 ;
2330
2334
@@ -2344,13 +2348,14 @@ size_t FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
2344
2348
// group, so we don't use a range-based for loop here.
2345
2349
for (auto PatItr = DagNotStrings.begin (), PatEnd = DagNotStrings.end ();
2346
2350
PatItr != PatEnd; ++PatItr) {
2347
- const Pattern &Pat = *PatItr;
2351
+ const Pattern &Pat = PatItr->DagNotPat ;
2352
+ const StringRef DNPrefix = PatItr->DagNotPrefix ;
2348
2353
assert ((Pat.getCheckTy () == Check::CheckDAG ||
2349
2354
Pat.getCheckTy () == Check::CheckNot) &&
2350
2355
" Invalid CHECK-DAG or CHECK-NOT!" );
2351
2356
2352
2357
if (Pat.getCheckTy () == Check::CheckNot) {
2353
- NotStrings.push_back (&Pat );
2358
+ NotStrings.push_back (&*PatItr );
2354
2359
continue ;
2355
2360
}
2356
2361
@@ -2367,7 +2372,7 @@ size_t FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
2367
2372
// With a group of CHECK-DAGs, a single mismatching means the match on
2368
2373
// that group of CHECK-DAGs fails immediately.
2369
2374
if (MatchResult.TheError || Req.VerboseVerbose ) {
2370
- if (Error Err = reportMatchResult (/* ExpectedMatch=*/ true , SM, Prefix ,
2375
+ if (Error Err = reportMatchResult (/* ExpectedMatch=*/ true , SM, DNPrefix ,
2371
2376
Pat.getLoc (), Pat, 1 , MatchBuffer,
2372
2377
std::move (MatchResult), Req, Diags)) {
2373
2378
cantFail (
@@ -2430,13 +2435,13 @@ size_t FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
2430
2435
}
2431
2436
if (!Req.VerboseVerbose )
2432
2437
cantFail (printMatch (
2433
- /* ExpectedMatch=*/ true , SM, Prefix , Pat.getLoc (), Pat, 1 , Buffer,
2438
+ /* ExpectedMatch=*/ true , SM, DNPrefix , Pat.getLoc (), Pat, 1 , Buffer,
2434
2439
Pattern::MatchResult (MatchPos, MatchLen, Error::success ()), Req,
2435
2440
Diags));
2436
2441
2437
2442
// Handle the end of a CHECK-DAG group.
2438
2443
if (std::next (PatItr) == PatEnd ||
2439
- std::next (PatItr)->getCheckTy () == Check::CheckNot) {
2444
+ std::next (PatItr)->DagNotPat . getCheckTy () == Check::CheckNot) {
2440
2445
if (!NotStrings.empty ()) {
2441
2446
// If there are CHECK-NOTs between two CHECK-DAGs or from CHECK to
2442
2447
// CHECK-DAG, verify that there are no 'not' strings occurred in that
0 commit comments