This revision was automatically updated to reflect the committed changes. Closed by commit rL356151: [ASTImporter] Fix import of NestedNameSpecifierLoc. (authored by balazske, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55358/new/ https://reviews.llvm.org/D55358 Files: cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/unittests/AST/ASTImporterTest.cpp Index: cfe/trunk/lib/AST/ASTImporter.cpp =================================================================== --- cfe/trunk/lib/AST/ASTImporter.cpp +++ cfe/trunk/lib/AST/ASTImporter.cpp @@ -8092,8 +8092,11 @@ case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: { + SourceLocation ToTLoc; + if (Error Err = importInto(ToTLoc, NNS.getTypeLoc().getBeginLoc())) + return std::move(Err); TypeSourceInfo *TSI = getToContext().getTrivialTypeSourceInfo( - QualType(Spec->getAsType(), 0)); + QualType(Spec->getAsType(), 0), ToTLoc); Builder.Extend(getToContext(), ToLocalBeginLoc, TSI->getTypeLoc(), ToLocalEndLoc); break; Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp =================================================================== --- cfe/trunk/unittests/AST/ASTImporterTest.cpp +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp @@ -1232,6 +1232,26 @@ has(fieldDecl(hasType(dependentSizedArrayType()))))))); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportBeginLocOfDeclRefExpr) { + Decl *FromTU = getTuDecl( + "class A { public: static int X; }; void f() { (void)A::X; }", Lang_CXX); + auto From = FirstDeclMatcher<FunctionDecl>().match( + FromTU, functionDecl(hasName("f"))); + ASSERT_TRUE(From); + ASSERT_TRUE( + cast<CStyleCastExpr>(cast<CompoundStmt>(From->getBody())->body_front()) + ->getSubExpr() + ->getBeginLoc() + .isValid()); + FunctionDecl *To = Import(From, Lang_CXX); + ASSERT_TRUE(To); + ASSERT_TRUE( + cast<CStyleCastExpr>(cast<CompoundStmt>(To->getBody())->body_front()) + ->getSubExpr() + ->getBeginLoc() + .isValid()); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) { Decl *FromTU = getTuDecl("template<class X> struct S{};", Lang_CXX);
Index: cfe/trunk/lib/AST/ASTImporter.cpp =================================================================== --- cfe/trunk/lib/AST/ASTImporter.cpp +++ cfe/trunk/lib/AST/ASTImporter.cpp @@ -8092,8 +8092,11 @@ case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: { + SourceLocation ToTLoc; + if (Error Err = importInto(ToTLoc, NNS.getTypeLoc().getBeginLoc())) + return std::move(Err); TypeSourceInfo *TSI = getToContext().getTrivialTypeSourceInfo( - QualType(Spec->getAsType(), 0)); + QualType(Spec->getAsType(), 0), ToTLoc); Builder.Extend(getToContext(), ToLocalBeginLoc, TSI->getTypeLoc(), ToLocalEndLoc); break; Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp =================================================================== --- cfe/trunk/unittests/AST/ASTImporterTest.cpp +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp @@ -1232,6 +1232,26 @@ has(fieldDecl(hasType(dependentSizedArrayType()))))))); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportBeginLocOfDeclRefExpr) { + Decl *FromTU = getTuDecl( + "class A { public: static int X; }; void f() { (void)A::X; }", Lang_CXX); + auto From = FirstDeclMatcher<FunctionDecl>().match( + FromTU, functionDecl(hasName("f"))); + ASSERT_TRUE(From); + ASSERT_TRUE( + cast<CStyleCastExpr>(cast<CompoundStmt>(From->getBody())->body_front()) + ->getSubExpr() + ->getBeginLoc() + .isValid()); + FunctionDecl *To = Import(From, Lang_CXX); + ASSERT_TRUE(To); + ASSERT_TRUE( + cast<CStyleCastExpr>(cast<CompoundStmt>(To->getBody())->body_front()) + ->getSubExpr() + ->getBeginLoc() + .isValid()); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) { Decl *FromTU = getTuDecl("template<class X> struct S{};", Lang_CXX);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits