[PATCH] D59934: Compare SourceLocations from different TUs by FileID

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 03:43:04 PDT 2019


balazske added a comment.

The following ASTImporterTest reproduces the assert:

  TEST_P(ASTImporterOptionSpecificTestBase, SourceLocationDifferentTU) {
    TranslationUnitDecl *ToTU = getToTuDecl("void f1();", Lang_CXX11);
    Decl *FromTU = getTuDecl("void f2();", Lang_CXX11, "input.cc");
    auto *ToF1 = FirstDeclMatcher<FunctionDecl>().match(ToTU, functionDecl());
    auto *FromF2 = FirstDeclMatcher<FunctionDecl>().match(FromTU, functionDecl());
  
    auto *ToF2 = Import(FromF2, Lang_CXX11);
  
    bool Before1 = ToTU->getASTContext().getSourceManager().isBeforeInTranslationUnit(ToF1->getLocation(), ToF2->getLocation());
    bool Before2 = ToTU->getASTContext().getSourceManager().isBeforeInTranslationUnit(ToF2->getLocation(), ToF1->getLocation());
    EXPECT_NE(Before1, Before2);
  }


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59934/new/

https://reviews.llvm.org/D59934





More information about the cfe-commits mailing list