@@ -373,10 +373,10 @@ namespace {
373
373
void print (raw_ostream &OS) const ;
374
374
375
375
void dumpResults () const ;
376
-
377
- bool verifyEqualTo (const UnqualifiedLookupFactory &&, const char * thisLabel,
378
- const char * otherLabel) const ;
379
-
376
+
377
+ bool verifyEqualTo (const UnqualifiedLookupFactory &&, StringRef thisLabel,
378
+ StringRef otherLabel) const ;
379
+
380
380
// / Legacy lookup is wrong here; we should NOT find this symbol.
381
381
bool shouldDiffer () const ;
382
382
StringRef getSourceFileName () const ;
@@ -515,8 +515,13 @@ void UnqualifiedLookupFactory::performUnqualifiedLookup() {
515
515
else
516
516
altLookup.lookupNamesIntroducedBy (contextAndIsCascadingUse);
517
517
518
- assert (
519
- verifyEqualTo (std::move (altLookup), " main lookup" , " alternate lookup" ));
518
+ const auto *ASTScopeLabel = " ASTScope lookup" ;
519
+ const auto *contextLabel = " context-bsed lookup" ;
520
+ const auto *mainLabel =
521
+ useASTScopesForLookup () ? ASTScopeLabel : contextLabel;
522
+ const auto *alternateLabel =
523
+ useASTScopesForLookup () ? contextLabel : ASTScopeLabel;
524
+ assert (verifyEqualTo (std::move (altLookup), mainLabel, alternateLabel));
520
525
}
521
526
}
522
527
@@ -1285,16 +1290,16 @@ StringRef UnqualifiedLookupFactory::getSourceFileName() const {
1285
1290
return DC->getParentSourceFile ()->getFilename ();
1286
1291
}
1287
1292
1288
- static void writeFirstLine (const UnqualifiedLookupFactory &ul, StringRef s) {
1293
+ static void writeFirstLine (const UnqualifiedLookupFactory &ul, llvm::Twine s) {
1289
1294
std::string line =
1290
1295
std::string (" In file: " ) + ul.getSourceFileName ().str () + " , " + s.str ();
1291
1296
writeLine (line);
1292
1297
}
1293
1298
1294
1299
static void writeInconsistent (const UnqualifiedLookupFactory &me,
1295
- const char * thisLabel,
1300
+ StringRef thisLabel,
1296
1301
const UnqualifiedLookupFactory &other,
1297
- const char * otherLabel, StringRef s) {
1302
+ StringRef otherLabel, llvm::Twine s) {
1298
1303
writeFirstLine (me, s);
1299
1304
other.dump ();
1300
1305
llvm::errs () << " \n " << thisLabel << " Results:\n " ;
@@ -1307,23 +1312,18 @@ static void writeInconsistent(const UnqualifiedLookupFactory &me,
1307
1312
#pragma mark comparing results
1308
1313
1309
1314
bool UnqualifiedLookupFactory::verifyEqualTo (
1310
- const UnqualifiedLookupFactory &&other, const char * thisLabel,
1311
- const char * otherLabel) const {
1315
+ const UnqualifiedLookupFactory &&other, const StringRef thisLabel,
1316
+ StringRef otherLabel) const {
1312
1317
if (shouldDiffer ()) {
1313
1318
return true ;
1314
1319
}
1315
- auto writeErr = [&](StringRef s) {
1320
+ auto writeErr = [&](llvm::Twine s) {
1316
1321
writeInconsistent (*this , thisLabel, other, otherLabel, s);
1317
1322
};
1318
1323
if (Results.size () != other.Results .size ()) {
1319
- const bool tooMany = Results.size () < other.Results .size ();
1320
- writeErr (std::string (tooMany ? " Found too many: " : " Found too few: " ) +
1321
- std::to_string (Results.size ()) + " vs " +
1322
- std::to_string (other.Results .size ()));
1323
- if (tooMany)
1324
- assert (false && " ASTScopeImpl found too many" );
1325
- else
1326
- assert (false && " ASTScopeImpl found too few" );
1324
+ writeErr (thisLabel + " found " + std::to_string (Results.size ()) + " but " +
1325
+ otherLabel + " found " + std::to_string (other.Results .size ()));
1326
+ assert (false && " mismatch in number of results" );
1327
1327
}
1328
1328
for (size_t i : indices (Results)) {
1329
1329
const auto &e = Results[i];
@@ -1338,7 +1338,7 @@ bool UnqualifiedLookupFactory::verifyEqualTo(
1338
1338
llvm::errs () << " ValueDecls differ but print same\n " ;
1339
1339
else {
1340
1340
writeErr (std::string ( " ValueDecls differ at " ) + std::to_string (i));
1341
- assert (false && " ASTScopeImpl found different Decl" );
1341
+ assert (false && " other lookup found different Decl" );
1342
1342
}
1343
1343
}
1344
1344
if (e.getDeclContext () != oe.getDeclContext ()) {
@@ -1353,7 +1353,7 @@ bool UnqualifiedLookupFactory::verifyEqualTo(
1353
1353
+ std::to_string (IndexOfFirstOuterResult)
1354
1354
+ std::string ( " , is: " )
1355
1355
+ std::to_string (other.IndexOfFirstOuterResult ));
1356
- assert (false && " ASTScopeImpl IndexOfFirstOuterResult differs" );
1356
+ assert (false && " other lookup IndexOfFirstOuterResult differs" );
1357
1357
}
1358
1358
if (recordedSF != other.recordedSF ) {
1359
1359
writeErr (std::string (" recordedSF differs: shouldBe: " ) +
@@ -1362,13 +1362,13 @@ bool UnqualifiedLookupFactory::verifyEqualTo(
1362
1362
std::string (" is: " ) +
1363
1363
(other.recordedSF ? other.recordedSF ->getFilename ().str ()
1364
1364
: std::string (" <no name>" )));
1365
- assert (false && " ASTScopeImpl recordedSF differs" );
1365
+ assert (false && " other lookup recordedSF differs" );
1366
1366
}
1367
1367
if (recordedSF && recordedIsCascadingUse != other.recordedIsCascadingUse ) {
1368
1368
writeErr (std::string (" recordedIsCascadingUse differs: shouldBe: " ) +
1369
1369
std::to_string (recordedIsCascadingUse) + std::string (" is: " ) +
1370
1370
std::to_string (other.recordedIsCascadingUse ));
1371
- assert (false && " ASTScopeImpl recordedIsCascadingUse differs" );
1371
+ assert (false && " other lookup recordedIsCascadingUse differs" );
1372
1372
}
1373
1373
return true ;
1374
1374
}
0 commit comments