summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorAdam Balogh <adam.balogh@ericsson.com>2018-06-15 06:45:39 +0000
committerAdam Balogh <adam.balogh@ericsson.com>2018-06-15 06:45:39 +0000
commitf4feb15d81a87656029dc5a9da5391665c255283 (patch)
treeed1339a29e7ee2bd9ddf7db1a1f1853cd805e17d /unittests
parent7653a4f768906f1c40620403bf7172e9bf5c9c21 (diff)
[ASTImporter] Corrected diagnostic client handling in tests.
ASTImporter tests may produce source file related warnings, the diagnostic client should be in correct state to handle it. Added 'beginSourceFile' to set the client state. Patch by: Balázs Kéri Differential Revision: https://reviews.llvm.org/D47445 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334804 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/AST/ASTImporterTest.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/unittests/AST/ASTImporterTest.cpp b/unittests/AST/ASTImporterTest.cpp
index 5e2dcf73fc..c81b4b338b 100644
--- a/unittests/AST/ASTImporterTest.cpp
+++ b/unittests/AST/ASTImporterTest.cpp
@@ -98,6 +98,9 @@ testImport(const std::string &FromCode, const ArgVector &FromArgs,
ASTContext &FromCtx = FromAST->getASTContext(),
&ToCtx = ToAST->getASTContext();
+ FromAST->enableSourceFileDiagnostics();
+ ToAST->enableSourceFileDiagnostics();
+
ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
@@ -172,7 +175,9 @@ class ASTImporterTestBase : public ::testing::TestWithParam<ArgVector> {
: Code(Code), FileName(FileName),
Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
this->FileName)),
- TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {}
+ TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {
+ Unit->enableSourceFileDiagnostics();
+ }
};
// We may have several From contexts and related translation units. In each
@@ -214,6 +219,7 @@ public:
ToCode = ToSrcCode;
assert(!ToAST);
ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+ ToAST->enableSourceFileDiagnostics();
ASTContext &FromCtx = FromTU.Unit->getASTContext(),
&ToCtx = ToAST->getASTContext();
@@ -261,6 +267,7 @@ public:
ToCode = ToSrcCode;
assert(!ToAST);
ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+ ToAST->enableSourceFileDiagnostics();
return ToAST->getASTContext().getTranslationUnitDecl();
}
@@ -274,6 +281,7 @@ public:
// Build the AST from an empty file.
ToAST =
tooling::buildASTFromCodeWithArgs(/*Code=*/"", ToArgs, "empty.cc");
+ ToAST->enableSourceFileDiagnostics();
}
// Create a virtual file in the To Ctx which corresponds to the file from