Index: cfe/trunk/lib/AST/ASTImporter.cpp =================================================================== --- cfe/trunk/lib/AST/ASTImporter.cpp +++ cfe/trunk/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(E)) { + return CXXConstCastExpr::Create(Importer.getToContext(), ToType, VK, ToOp, + ToWritten, ToOperatorLoc, ToRParenLoc, + ToAngleBrackets); } else { return nullptr; } Index: cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp =================================================================== --- cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp +++ cfe/trunk/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(b); + const B *c2 = static_cast(b); + const B *c3 = reinterpret_cast(b); + A *c4 = const_cast(b); +} Index: cfe/trunk/test/Import/cxx-casts/test.cpp =================================================================== --- cfe/trunk/test/Import/cxx-casts/test.cpp +++ cfe/trunk/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: + +// CHECK: CXXStaticCastExpr +// CHECK-SAME: static_cast +// CHECK-SAME: + +// CHECK: CXXReinterpretCastExpr +// CHECK-SAME: reinterpret_cast +// CHECK-SAME: + +// CHECK: CXXConstCastExpr +// CHECK-SAME: const_cast +// CHECK-SAME: + +void expr() { + f(); +} Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp =================================================================== --- cfe/trunk/tools/clang-import-test/clang-import-test.cpp +++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp @@ -194,6 +194,8 @@ Inv->getLangOpts()->ThreadsafeStatics = false; Inv->getLangOpts()->AccessControl = false; Inv->getLangOpts()->DollarIdents = true; + // Needed for testing dynamic_cast. + Inv->getLangOpts()->RTTI = true; Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo); Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();