teemperor created this revision. Herald added a subscriber: martong. Herald added a reviewer: a.sidorin.
Repository: rC Clang https://reviews.llvm.org/D50932 Files: lib/AST/ASTImporter.cpp test/Import/cxx-casts/Inputs/F.cpp test/Import/cxx-casts/test.cpp tools/clang-import-test/clang-import-test.cpp Index: tools/clang-import-test/clang-import-test.cpp =================================================================== --- tools/clang-import-test/clang-import-test.cpp +++ tools/clang-import-test/clang-import-test.cpp @@ -194,6 +194,7 @@ Inv->getLangOpts()->ThreadsafeStatics = false; Inv->getLangOpts()->AccessControl = false; Inv->getLangOpts()->DollarIdents = true; + Inv->getLangOpts()->RTTI = true; Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo); Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); Index: test/Import/cxx-casts/test.cpp =================================================================== --- /dev/null +++ test/Import/cxx-casts/test.cpp @@ -0,0 +1,21 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: CXXDynamicCastExpr +// CHECK-SAME: dynamic_cast +// CHECK-SAME: <Dynamic> + +// CHECK: CXXStaticCastExpr +// CHECK-SAME: static_cast +// CHECK-SAME: <BaseToDerived (A)> + +// CHECK: CXXReinterpretCastExpr +// CHECK-SAME: reinterpret_cast +// CHECK-SAME: <BitCast> + +// CHECK: CXXConstCastExpr +// CHECK-SAME: const_cast +// CHECK-SAME: <NoOp> + +void expr() { + f(); +} Index: test/Import/cxx-casts/Inputs/F.cpp =================================================================== --- /dev/null +++ test/Import/cxx-casts/Inputs/F.cpp @@ -0,0 +1,12 @@ +struct A { + virtual ~A() {} +}; +struct B : public A {}; + +void f() { + const A *b = new B(); + const B *c1 = dynamic_cast<const B *>(b); + const B *c2 = static_cast<const B *>(b); + const B *c3 = reinterpret_cast<const B *>(b); + A *c4 = const_cast<A *>(b); +} Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -6897,6 +6897,10 @@ return CXXReinterpretCastExpr::Create( Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath, ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets); + } else if (isa<CXXConstCastExpr>(E)) { + return CXXConstCastExpr::Create(Importer.getToContext(), ToType, VK, ToOp, + ToWritten, ToOperatorLoc, ToRParenLoc, + ToAngleBrackets); } else { return nullptr; }
Index: tools/clang-import-test/clang-import-test.cpp =================================================================== --- tools/clang-import-test/clang-import-test.cpp +++ tools/clang-import-test/clang-import-test.cpp @@ -194,6 +194,7 @@ Inv->getLangOpts()->ThreadsafeStatics = false; Inv->getLangOpts()->AccessControl = false; Inv->getLangOpts()->DollarIdents = true; + Inv->getLangOpts()->RTTI = true; Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo); Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); Index: test/Import/cxx-casts/test.cpp =================================================================== --- /dev/null +++ test/Import/cxx-casts/test.cpp @@ -0,0 +1,21 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: CXXDynamicCastExpr +// CHECK-SAME: dynamic_cast +// CHECK-SAME: <Dynamic> + +// CHECK: CXXStaticCastExpr +// CHECK-SAME: static_cast +// CHECK-SAME: <BaseToDerived (A)> + +// CHECK: CXXReinterpretCastExpr +// CHECK-SAME: reinterpret_cast +// CHECK-SAME: <BitCast> + +// CHECK: CXXConstCastExpr +// CHECK-SAME: const_cast +// CHECK-SAME: <NoOp> + +void expr() { + f(); +} Index: test/Import/cxx-casts/Inputs/F.cpp =================================================================== --- /dev/null +++ test/Import/cxx-casts/Inputs/F.cpp @@ -0,0 +1,12 @@ +struct A { + virtual ~A() {} +}; +struct B : public A {}; + +void f() { + const A *b = new B(); + const B *c1 = dynamic_cast<const B *>(b); + const B *c2 = static_cast<const B *>(b); + const B *c3 = reinterpret_cast<const B *>(b); + A *c4 = const_cast<A *>(b); +} Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -6897,6 +6897,10 @@ return CXXReinterpretCastExpr::Create( Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath, ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets); + } else if (isa<CXXConstCastExpr>(E)) { + return CXXConstCastExpr::Create(Importer.getToContext(), ToType, VK, ToOp, + ToWritten, ToOperatorLoc, ToRParenLoc, + ToAngleBrackets); } else { return nullptr; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits