aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Interpreter/InterpreterTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Interpreter/InterpreterTest.cpp')
-rw-r--r--clang/unittests/Interpreter/InterpreterTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp
index a2e960f..30b051e 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -381,4 +381,26 @@ TEST_F(InterpreterTest, Value) {
EXPECT_TRUE(V9.isManuallyAlloc());
}
+TEST_F(InterpreterTest, TranslationUnit_CanonicalDecl) {
+ std::vector<const char *> Args;
+ std::unique_ptr<Interpreter> Interp = createInterpreter(Args);
+
+ Sema &sema = Interp->getCompilerInstance()->getSema();
+
+ llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+
+ TranslationUnitDecl *TU =
+ sema.getASTContext().getTranslationUnitDecl()->getCanonicalDecl();
+
+ llvm::cantFail(Interp->ParseAndExecute("long y = 84;"));
+
+ EXPECT_EQ(TU,
+ sema.getASTContext().getTranslationUnitDecl()->getCanonicalDecl());
+
+ llvm::cantFail(Interp->ParseAndExecute("char z = 'z';"));
+
+ EXPECT_EQ(TU,
+ sema.getASTContext().getTranslationUnitDecl()->getCanonicalDecl());
+}
+
} // end anonymous namespace