summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:35 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:35 +0000
commit6694ed095d6b27a2c92ec4fd63664fcd88a05749 (patch)
tree0633c29bd8350e306f3a24a30f3f6045efd35420 /unittests
parentd5dc75c5cf109efe52b1da32ec44a667389a0f0a (diff)
Notes
Diffstat (limited to 'unittests')
-rw-r--r--unittests/AST/ExternalASTSourceTest.cpp4
-rw-r--r--unittests/ASTMatchers/ASTMatchersTraversalTest.cpp9
-rw-r--r--unittests/Basic/SourceManagerTest.cpp24
-rw-r--r--unittests/Format/FormatTestJS.cpp4
-rw-r--r--unittests/Frontend/CodeGenActionTest.cpp4
-rw-r--r--unittests/Frontend/FrontendActionTest.cpp20
-rw-r--r--unittests/Lex/LexerTest.cpp8
-rw-r--r--unittests/Lex/PPCallbacksTest.cpp18
-rw-r--r--unittests/Lex/PPConditionalDirectiveRecordTest.cpp8
9 files changed, 51 insertions, 48 deletions
diff --git a/unittests/AST/ExternalASTSourceTest.cpp b/unittests/AST/ExternalASTSourceTest.cpp
index 4b3bb3e2b69b..513ff5b99fad 100644
--- a/unittests/AST/ExternalASTSourceTest.cpp
+++ b/unittests/AST/ExternalASTSourceTest.cpp
@@ -49,14 +49,14 @@ bool testExternalASTSource(ExternalASTSource *Source,
CompilerInstance Compiler;
Compiler.createDiagnostics();
- CompilerInvocation *Invocation = new CompilerInvocation;
+ auto Invocation = std::make_shared<CompilerInvocation>();
Invocation->getPreprocessorOpts().addRemappedFile(
"test.cc", MemoryBuffer::getMemBuffer(FileContents).release());
const char *Args[] = { "test.cc" };
CompilerInvocation::CreateFromArgs(*Invocation, Args,
Args + array_lengthof(Args),
Compiler.getDiagnostics());
- Compiler.setInvocation(Invocation);
+ Compiler.setInvocation(std::move(Invocation));
TestFrontendAction Action(Source);
return Compiler.ExecuteAction(Action);
diff --git a/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 67a4a3b2fc09..5957c7fa41da 100644
--- a/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -222,9 +222,12 @@ TEST(HasDeclaration, HasDeclarationOfEnumType) {
}
TEST(HasDeclaration, HasGetDeclTraitTest) {
- EXPECT_TRUE(internal::has_getDecl<TypedefType>::value);
- EXPECT_TRUE(internal::has_getDecl<RecordType>::value);
- EXPECT_FALSE(internal::has_getDecl<TemplateSpecializationType>::value);
+ static_assert(internal::has_getDecl<TypedefType>::value,
+ "Expected TypedefType to have a getDecl.");
+ static_assert(internal::has_getDecl<RecordType>::value,
+ "Expected RecordType to have a getDecl.");
+ static_assert(!internal::has_getDecl<TemplateSpecializationType>::value,
+ "Expected TemplateSpecializationType to *not* have a getDecl.");
}
TEST(HasDeclaration, HasDeclarationOfTypeWithDecl) {
diff --git a/unittests/Basic/SourceManagerTest.cpp b/unittests/Basic/SourceManagerTest.cpp
index f41876147cdd..a967b0ec7c21 100644
--- a/unittests/Basic/SourceManagerTest.cpp
+++ b/unittests/Basic/SourceManagerTest.cpp
@@ -78,10 +78,10 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
SourceMgr.setMainFileID(mainFileID);
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
- &*Target);
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
- HeaderInfo, ModLoader,
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, LangOpts, &*Target);
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModLoader,
/*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
@@ -198,10 +198,10 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
- &*Target);
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
- HeaderInfo, ModLoader,
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, LangOpts, &*Target);
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModLoader,
/*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
@@ -298,10 +298,10 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) {
SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
- &*Target);
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
- HeaderInfo, ModLoader,
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, LangOpts, &*Target);
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModLoader,
/*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index 90c99317bd79..59f4a4f6dcfe 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -541,8 +541,8 @@ TEST_F(FormatTestJS, FunctionLiterals) {
" foo();\n"
" bar();\n"
" },\n"
- " this, arg1IsReallyLongAndNeeedsLineBreaks,\n"
- " arg3IsReallyLongAndNeeedsLineBreaks);");
+ " this, arg1IsReallyLongAndNeedsLineBreaks,\n"
+ " arg3IsReallyLongAndNeedsLineBreaks);");
verifyFormat("var closure = goog.bind(function() { // comment\n"
" foo();\n"
" bar();\n"
diff --git a/unittests/Frontend/CodeGenActionTest.cpp b/unittests/Frontend/CodeGenActionTest.cpp
index 356b5130fcbe..1d2a50c8bc20 100644
--- a/unittests/Frontend/CodeGenActionTest.cpp
+++ b/unittests/Frontend/CodeGenActionTest.cpp
@@ -41,7 +41,7 @@ public:
TEST(CodeGenTest, TestNullCodeGen) {
- CompilerInvocation *Invocation = new CompilerInvocation;
+ auto Invocation = std::make_shared<CompilerInvocation>();
Invocation->getPreprocessorOpts().addRemappedFile(
"test.cc",
MemoryBuffer::getMemBuffer("").release());
@@ -50,7 +50,7 @@ TEST(CodeGenTest, TestNullCodeGen) {
Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance Compiler;
- Compiler.setInvocation(Invocation);
+ Compiler.setInvocation(std::move(Invocation));
Compiler.createDiagnostics();
EXPECT_TRUE(Compiler.hasDiagnostics());
diff --git a/unittests/Frontend/FrontendActionTest.cpp b/unittests/Frontend/FrontendActionTest.cpp
index c3e6adb6324d..dd6be5fd4b98 100644
--- a/unittests/Frontend/FrontendActionTest.cpp
+++ b/unittests/Frontend/FrontendActionTest.cpp
@@ -79,7 +79,7 @@ private:
};
TEST(ASTFrontendAction, Sanity) {
- CompilerInvocation *invocation = new CompilerInvocation;
+ auto invocation = std::make_shared<CompilerInvocation>();
invocation->getPreprocessorOpts().addRemappedFile(
"test.cc",
MemoryBuffer::getMemBuffer("int main() { float x; }").release());
@@ -88,7 +88,7 @@ TEST(ASTFrontendAction, Sanity) {
invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance compiler;
- compiler.setInvocation(invocation);
+ compiler.setInvocation(std::move(invocation));
compiler.createDiagnostics();
TestASTFrontendAction test_action;
@@ -99,7 +99,7 @@ TEST(ASTFrontendAction, Sanity) {
}
TEST(ASTFrontendAction, IncrementalParsing) {
- CompilerInvocation *invocation = new CompilerInvocation;
+ auto invocation = std::make_shared<CompilerInvocation>();
invocation->getPreprocessorOpts().addRemappedFile(
"test.cc",
MemoryBuffer::getMemBuffer("int main() { float x; }").release());
@@ -108,7 +108,7 @@ TEST(ASTFrontendAction, IncrementalParsing) {
invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance compiler;
- compiler.setInvocation(invocation);
+ compiler.setInvocation(std::move(invocation));
compiler.createDiagnostics();
TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true);
@@ -119,7 +119,7 @@ TEST(ASTFrontendAction, IncrementalParsing) {
}
TEST(ASTFrontendAction, LateTemplateIncrementalParsing) {
- CompilerInvocation *invocation = new CompilerInvocation;
+ auto invocation = std::make_shared<CompilerInvocation>();
invocation->getLangOpts()->CPlusPlus = true;
invocation->getLangOpts()->DelayedTemplateParsing = true;
invocation->getPreprocessorOpts().addRemappedFile(
@@ -135,7 +135,7 @@ TEST(ASTFrontendAction, LateTemplateIncrementalParsing) {
invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance compiler;
- compiler.setInvocation(invocation);
+ compiler.setInvocation(std::move(invocation));
compiler.createDiagnostics();
TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true,
@@ -172,7 +172,7 @@ public:
};
TEST(PreprocessorFrontendAction, EndSourceFile) {
- CompilerInvocation *Invocation = new CompilerInvocation;
+ auto Invocation = std::make_shared<CompilerInvocation>();
Invocation->getPreprocessorOpts().addRemappedFile(
"test.cc",
MemoryBuffer::getMemBuffer("int main() { float x; }").release());
@@ -181,7 +181,7 @@ TEST(PreprocessorFrontendAction, EndSourceFile) {
Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance Compiler;
- Compiler.setInvocation(Invocation);
+ Compiler.setInvocation(std::move(Invocation));
Compiler.createDiagnostics();
TestPPCallbacks *Callbacks = new TestPPCallbacks;
@@ -231,7 +231,7 @@ struct TypoDiagnosticConsumer : public DiagnosticConsumer {
};
TEST(ASTFrontendAction, ExternalSemaSource) {
- auto *Invocation = new CompilerInvocation;
+ auto Invocation = std::make_shared<CompilerInvocation>();
Invocation->getLangOpts()->CPlusPlus = true;
Invocation->getPreprocessorOpts().addRemappedFile(
"test.cc", MemoryBuffer::getMemBuffer("void fooo();\n"
@@ -242,7 +242,7 @@ TEST(ASTFrontendAction, ExternalSemaSource) {
Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance Compiler;
- Compiler.setInvocation(Invocation);
+ Compiler.setInvocation(std::move(Invocation));
auto *TDC = new TypoDiagnosticConsumer;
Compiler.createDiagnostics(TDC, /*ShouldOwnClient=*/true);
Compiler.setExternalSemaSource(new TypoExternalSemaSource(Compiler));
diff --git a/unittests/Lex/LexerTest.cpp b/unittests/Lex/LexerTest.cpp
index 204601818152..918167bf43c5 100644
--- a/unittests/Lex/LexerTest.cpp
+++ b/unittests/Lex/LexerTest.cpp
@@ -64,10 +64,10 @@ protected:
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
- Target.get());
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
- HeaderInfo, ModLoader, /*IILookup =*/nullptr,
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, LangOpts, Target.get());
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
PP.EnterMainSourceFile();
diff --git a/unittests/Lex/PPCallbacksTest.cpp b/unittests/Lex/PPCallbacksTest.cpp
index cbce5c6e1676..064abafc4a88 100644
--- a/unittests/Lex/PPCallbacksTest.cpp
+++ b/unittests/Lex/PPCallbacksTest.cpp
@@ -162,13 +162,12 @@ protected:
VoidModuleLoader ModLoader;
- IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts = new HeaderSearchOptions();
- HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts,
- Target.get());
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, LangOpts, Target.get());
AddFakeHeader(HeaderInfo, HeaderPath, SystemHeader);
- IntrusiveRefCntPtr<PreprocessorOptions> PPOpts = new PreprocessorOptions();
- Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader,
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModLoader,
/*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
@@ -199,11 +198,12 @@ protected:
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags,
- OpenCLLangOpts, Target.get());
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, OpenCLLangOpts, Target.get());
- Preprocessor PP(new PreprocessorOptions(), Diags, OpenCLLangOpts, SourceMgr,
- HeaderInfo, ModLoader, /*IILookup =*/nullptr,
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags,
+ OpenCLLangOpts, SourceMgr, HeaderInfo, ModLoader,
+ /*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
diff --git a/unittests/Lex/PPConditionalDirectiveRecordTest.cpp b/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
index bceeac57ea61..dccfffdb2c15 100644
--- a/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
+++ b/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
@@ -93,10 +93,10 @@ TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
- Target.get());
- Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr,
- HeaderInfo, ModLoader,
+ HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
+ Diags, LangOpts, Target.get());
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModLoader,
/*IILookup =*/nullptr,
/*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);