aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/AST/ASTVectorTest.cpp5
-rw-r--r--clang/unittests/AST/CommentLexer.cpp6
-rw-r--r--clang/unittests/AST/CommentParser.cpp5
-rw-r--r--clang/unittests/AST/CommentTextTest.cpp2
-rw-r--r--clang/unittests/Analysis/CMakeLists.txt1
-rw-r--r--clang/unittests/Analysis/LifetimeSafetyTest.cpp710
-rw-r--r--clang/unittests/Analysis/MacroExpansionContextTest.cpp7
-rw-r--r--clang/unittests/Analysis/UnsafeBufferUsageTest.cpp7
-rw-r--r--clang/unittests/Basic/DiagnosticTest.cpp14
-rw-r--r--clang/unittests/Basic/FileManagerTest.cpp12
-rw-r--r--clang/unittests/Basic/SarifTest.cpp7
-rw-r--r--clang/unittests/Basic/SourceManagerTest.cpp5
-rw-r--r--clang/unittests/CodeGen/TestCompiler.h2
-rw-r--r--clang/unittests/Driver/DXCModeTest.cpp20
-rw-r--r--clang/unittests/Driver/SanitizerArgsTest.cpp5
-rw-r--r--clang/unittests/Driver/SimpleDiagnosticConsumer.h9
-rw-r--r--clang/unittests/Driver/ToolChainTest.cpp79
-rw-r--r--clang/unittests/Format/BracesInserterTest.cpp6
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp136
-rw-r--r--clang/unittests/Format/FormatTestComments.cpp10
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp12
-rw-r--r--clang/unittests/Format/FormatTestSelective.cpp23
-rw-r--r--clang/unittests/Format/IntegerLiteralSeparatorTest.cpp29
-rw-r--r--clang/unittests/Format/SortIncludesTest.cpp4
-rw-r--r--clang/unittests/Format/TokenAnnotatorTest.cpp4
-rw-r--r--clang/unittests/Frontend/ASTUnitTest.cpp3
-rw-r--r--clang/unittests/Frontend/CodeGenActionTest.cpp36
-rw-r--r--clang/unittests/Frontend/CompilerInstanceTest.cpp4
-rw-r--r--clang/unittests/Frontend/PCHPreambleTest.cpp2
-rw-r--r--clang/unittests/Frontend/ReparseWorkingDirTest.cpp4
-rw-r--r--clang/unittests/Frontend/SearchPathTest.cpp4
-rw-r--r--clang/unittests/Frontend/TextDiagnosticTest.cpp3
-rw-r--r--clang/unittests/Frontend/UtilsTest.cpp2
-rw-r--r--clang/unittests/Interpreter/InterpreterTest.cpp26
-rw-r--r--clang/unittests/Lex/DependencyDirectivesScannerTest.cpp29
-rw-r--r--clang/unittests/Lex/HeaderSearchTest.cpp7
-rw-r--r--clang/unittests/Lex/LexerTest.cpp5
-rw-r--r--clang/unittests/Lex/ModuleDeclStateTest.cpp5
-rw-r--r--clang/unittests/Lex/PPCallbacksTest.cpp5
-rw-r--r--clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp5
-rw-r--r--clang/unittests/Lex/PPDependencyDirectivesTest.cpp7
-rw-r--r--clang/unittests/Lex/PPMemoryAllocationsTest.cpp5
-rw-r--r--clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp204
-rw-r--r--clang/unittests/Sema/SemaNoloadLookupTest.cpp2
-rw-r--r--clang/unittests/Serialization/ForceCheckFileInputTest.cpp4
-rw-r--r--clang/unittests/Serialization/LoadSpecLazilyTest.cpp2
-rw-r--r--clang/unittests/Serialization/ModuleCacheTest.cpp8
-rw-r--r--clang/unittests/Serialization/NoCommentsTest.cpp2
-rw-r--r--clang/unittests/Serialization/PreambleInNamedModulesTest.cpp4
-rw-r--r--clang/unittests/Serialization/VarDeclConstantInitTest.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp6
-rw-r--r--clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp4
-rw-r--r--clang/unittests/StaticAnalyzer/CallEventTest.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp6
-rw-r--r--clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp8
-rw-r--r--clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp4
-rw-r--r--clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp4
-rw-r--r--clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp24
-rw-r--r--clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp3
-rw-r--r--clang/unittests/StaticAnalyzer/SValTest.cpp6
-rw-r--r--clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp6
-rw-r--r--clang/unittests/Support/TimeProfilerTest.cpp3
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp3
-rw-r--r--clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp12
-rw-r--r--clang/unittests/Tooling/RefactoringTest.cpp9
-rw-r--r--clang/unittests/Tooling/RewriterTestContext.h9
-rw-r--r--clang/unittests/Tooling/Syntax/TokensTest.cpp7
-rw-r--r--clang/unittests/Tooling/Syntax/TreeTestBase.cpp2
-rw-r--r--clang/unittests/Tooling/Syntax/TreeTestBase.h5
-rw-r--r--clang/unittests/Tooling/ToolingTest.cpp78
74 files changed, 1173 insertions, 535 deletions
diff --git a/clang/unittests/AST/ASTVectorTest.cpp b/clang/unittests/AST/ASTVectorTest.cpp
index 66003b4..03da549 100644
--- a/clang/unittests/AST/ASTVectorTest.cpp
+++ b/clang/unittests/AST/ASTVectorTest.cpp
@@ -26,14 +26,13 @@ namespace {
class ASTVectorTest : public ::testing::Test {
protected:
ASTVectorTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), Idents(LangOpts, nullptr),
Ctxt(LangOpts, SourceMgr, Idents, Sels, Builtins, TU_Complete) {}
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/AST/CommentLexer.cpp b/clang/unittests/AST/CommentLexer.cpp
index dc10dae..99f4691 100644
--- a/clang/unittests/AST/CommentLexer.cpp
+++ b/clang/unittests/AST/CommentLexer.cpp
@@ -27,13 +27,12 @@ namespace {
class CommentLexerTest : public ::testing::Test {
protected:
CommentLexerTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), Traits(Allocator, CommentOptions()) {}
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
@@ -2006,4 +2005,3 @@ TEST_F(CommentLexerTest, MultipleComments) {
} // end namespace comments
} // end namespace clang
-
diff --git a/clang/unittests/AST/CommentParser.cpp b/clang/unittests/AST/CommentParser.cpp
index 67fabe5..3bd2bdb 100644
--- a/clang/unittests/AST/CommentParser.cpp
+++ b/clang/unittests/AST/CommentParser.cpp
@@ -33,13 +33,12 @@ const bool MY_DEBUG = true;
class CommentParserTest : public ::testing::Test {
protected:
CommentParserTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), Traits(Allocator, CommentOptions()) {}
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/AST/CommentTextTest.cpp b/clang/unittests/AST/CommentTextTest.cpp
index 84ec51a..675173c 100644
--- a/clang/unittests/AST/CommentTextTest.cpp
+++ b/clang/unittests/AST/CommentTextTest.cpp
@@ -44,7 +44,7 @@ protected:
// shouldn't matter.
RawComment Comment(SourceMgr, CommentRange, EmptyOpts, /*Merged=*/true);
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs, DiagOpts);
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts);
return Comment.getFormattedText(SourceMgr, Diags);
}
};
diff --git a/clang/unittests/Analysis/CMakeLists.txt b/clang/unittests/Analysis/CMakeLists.txt
index 059a748..52e7d28 100644
--- a/clang/unittests/Analysis/CMakeLists.txt
+++ b/clang/unittests/Analysis/CMakeLists.txt
@@ -4,6 +4,7 @@ add_clang_unittest(ClangAnalysisTests
CloneDetectionTest.cpp
ExprMutationAnalyzerTest.cpp
IntervalPartitionTest.cpp
+ LifetimeSafetyTest.cpp
MacroExpansionContextTest.cpp
UnsafeBufferUsageTest.cpp
CLANG_LIBS
diff --git a/clang/unittests/Analysis/LifetimeSafetyTest.cpp b/clang/unittests/Analysis/LifetimeSafetyTest.cpp
new file mode 100644
index 0000000..a48dc45
--- /dev/null
+++ b/clang/unittests/Analysis/LifetimeSafetyTest.cpp
@@ -0,0 +1,710 @@
+//===- LifetimeSafetyTest.cpp - Lifetime Safety Tests -*---------- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/Analyses/LifetimeSafety.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Testing/TestAST.h"
+#include "llvm/ADT/StringMap.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include <optional>
+#include <vector>
+
+namespace clang::lifetimes::internal {
+namespace {
+
+using namespace ast_matchers;
+using ::testing::UnorderedElementsAreArray;
+
+// A helper class to run the full lifetime analysis on a piece of code
+// and provide an interface for querying the results.
+class LifetimeTestRunner {
+public:
+ LifetimeTestRunner(llvm::StringRef Code) {
+ std::string FullCode = R"(
+ #define POINT(name) void("__lifetime_test_point_" #name)
+ struct MyObj { ~MyObj() {} int i; };
+ )";
+ FullCode += Code.str();
+
+ AST = std::make_unique<clang::TestAST>(FullCode);
+ ASTCtx = &AST->context();
+
+ // Find the target function using AST matchers.
+ auto MatchResult =
+ match(functionDecl(hasName("target")).bind("target"), *ASTCtx);
+ auto *FD = selectFirst<FunctionDecl>("target", MatchResult);
+ if (!FD) {
+ ADD_FAILURE() << "Test case must have a function named 'target'";
+ return;
+ }
+ AnalysisCtx = std::make_unique<AnalysisDeclContext>(nullptr, FD);
+ CFG::BuildOptions &BuildOptions = AnalysisCtx->getCFGBuildOptions();
+ BuildOptions.setAllAlwaysAdd();
+ BuildOptions.AddImplicitDtors = true;
+ BuildOptions.AddTemporaryDtors = true;
+
+ // Run the main analysis.
+ Analysis = std::make_unique<LifetimeSafetyAnalysis>(*AnalysisCtx);
+ Analysis->run();
+
+ AnnotationToPointMap = Analysis->getTestPoints();
+ }
+
+ LifetimeSafetyAnalysis &getAnalysis() { return *Analysis; }
+ ASTContext &getASTContext() { return *ASTCtx; }
+
+ ProgramPoint getProgramPoint(llvm::StringRef Annotation) {
+ auto It = AnnotationToPointMap.find(Annotation);
+ if (It == AnnotationToPointMap.end()) {
+ ADD_FAILURE() << "Annotation '" << Annotation << "' not found.";
+ return nullptr;
+ }
+ return It->second;
+ }
+
+private:
+ std::unique_ptr<TestAST> AST;
+ ASTContext *ASTCtx = nullptr;
+ std::unique_ptr<AnalysisDeclContext> AnalysisCtx;
+ std::unique_ptr<LifetimeSafetyAnalysis> Analysis;
+ llvm::StringMap<ProgramPoint> AnnotationToPointMap;
+};
+
+// A convenience wrapper that uses the LifetimeSafetyAnalysis public API.
+class LifetimeTestHelper {
+public:
+ LifetimeTestHelper(LifetimeTestRunner &Runner)
+ : Runner(Runner), Analysis(Runner.getAnalysis()) {}
+
+ std::optional<OriginID> getOriginForDecl(llvm::StringRef VarName) {
+ auto *VD = findDecl<ValueDecl>(VarName);
+ if (!VD)
+ return std::nullopt;
+ auto OID = Analysis.getOriginIDForDecl(VD);
+ if (!OID)
+ ADD_FAILURE() << "Origin for '" << VarName << "' not found.";
+ return OID;
+ }
+
+ std::optional<LoanID> getLoanForVar(llvm::StringRef VarName) {
+ auto *VD = findDecl<VarDecl>(VarName);
+ if (!VD)
+ return std::nullopt;
+ std::vector<LoanID> LID = Analysis.getLoanIDForVar(VD);
+ if (LID.empty()) {
+ ADD_FAILURE() << "Loan for '" << VarName << "' not found.";
+ return std::nullopt;
+ }
+ // TODO: Support retrieving more than one loans to a var.
+ if (LID.size() > 1) {
+ ADD_FAILURE() << "More than 1 loans found for '" << VarName;
+ return std::nullopt;
+ }
+ return LID[0];
+ }
+
+ std::optional<LoanSet> getLoansAtPoint(OriginID OID,
+ llvm::StringRef Annotation) {
+ ProgramPoint PP = Runner.getProgramPoint(Annotation);
+ if (!PP)
+ return std::nullopt;
+ return Analysis.getLoansAtPoint(OID, PP);
+ }
+
+ std::optional<LoanSet> getExpiredLoansAtPoint(llvm::StringRef Annotation) {
+ ProgramPoint PP = Runner.getProgramPoint(Annotation);
+ if (!PP)
+ return std::nullopt;
+ return Analysis.getExpiredLoansAtPoint(PP);
+ }
+
+private:
+ template <typename DeclT> DeclT *findDecl(llvm::StringRef Name) {
+ auto &Ctx = Runner.getASTContext();
+ auto Results = match(valueDecl(hasName(Name)).bind("v"), Ctx);
+ if (Results.empty()) {
+ ADD_FAILURE() << "Declaration '" << Name << "' not found in AST.";
+ return nullptr;
+ }
+ return const_cast<DeclT *>(selectFirst<DeclT>("v", Results));
+ }
+
+ LifetimeTestRunner &Runner;
+ LifetimeSafetyAnalysis &Analysis;
+};
+
+// ========================================================================= //
+// GTest Matchers & Fixture
+// ========================================================================= //
+
+// A helper class to represent a set of loans, identified by variable names.
+class LoanSetInfo {
+public:
+ LoanSetInfo(const std::vector<std::string> &Vars, LifetimeTestHelper &H)
+ : LoanVars(Vars), Helper(H) {}
+ std::vector<std::string> LoanVars;
+ LifetimeTestHelper &Helper;
+};
+
+// It holds the name of the origin variable and a reference to the helper.
+class OriginInfo {
+public:
+ OriginInfo(llvm::StringRef OriginVar, LifetimeTestHelper &Helper)
+ : OriginVar(OriginVar), Helper(Helper) {}
+ llvm::StringRef OriginVar;
+ LifetimeTestHelper &Helper;
+};
+
+/// Matcher to verify the set of loans held by an origin at a specific
+/// program point.
+///
+/// This matcher is intended to be used with an \c OriginInfo object.
+///
+/// \param LoanVars A vector of strings, where each string is the name of a
+/// variable expected to be the source of a loan.
+/// \param Annotation A string identifying the program point (created with
+/// POINT()) where the check should be performed.
+MATCHER_P2(HasLoansToImpl, LoanVars, Annotation, "") {
+ const OriginInfo &Info = arg;
+ std::optional<OriginID> OIDOpt = Info.Helper.getOriginForDecl(Info.OriginVar);
+ if (!OIDOpt) {
+ *result_listener << "could not find origin for '" << Info.OriginVar.str()
+ << "'";
+ return false;
+ }
+
+ std::optional<LoanSet> ActualLoansSetOpt =
+ Info.Helper.getLoansAtPoint(*OIDOpt, Annotation);
+ if (!ActualLoansSetOpt) {
+ *result_listener << "could not get a valid loan set at point '"
+ << Annotation << "'";
+ return false;
+ }
+ std::vector<LoanID> ActualLoans(ActualLoansSetOpt->begin(),
+ ActualLoansSetOpt->end());
+
+ std::vector<LoanID> ExpectedLoans;
+ for (const auto &LoanVar : LoanVars) {
+ std::optional<LoanID> ExpectedLIDOpt = Info.Helper.getLoanForVar(LoanVar);
+ if (!ExpectedLIDOpt) {
+ *result_listener << "could not find loan for var '" << LoanVar << "'";
+ return false;
+ }
+ ExpectedLoans.push_back(*ExpectedLIDOpt);
+ }
+
+ return ExplainMatchResult(UnorderedElementsAreArray(ExpectedLoans),
+ ActualLoans, result_listener);
+}
+
+/// Matcher to verify that the complete set of expired loans at a program point
+/// matches the expected loan set.
+MATCHER_P(AreExpiredAt, Annotation, "") {
+ const LoanSetInfo &Info = arg;
+ auto &Helper = Info.Helper;
+
+ auto ActualExpiredSetOpt = Helper.getExpiredLoansAtPoint(Annotation);
+ if (!ActualExpiredSetOpt) {
+ *result_listener << "could not get a valid expired loan set at point '"
+ << Annotation << "'";
+ return false;
+ }
+ std::vector<LoanID> ActualExpiredLoans(ActualExpiredSetOpt->begin(),
+ ActualExpiredSetOpt->end());
+ std::vector<LoanID> ExpectedExpiredLoans;
+ for (const auto &VarName : Info.LoanVars) {
+ auto LoanIDOpt = Helper.getLoanForVar(VarName);
+ if (!LoanIDOpt) {
+ *result_listener << "could not find a loan for variable '" << VarName
+ << "'";
+ return false;
+ }
+ ExpectedExpiredLoans.push_back(*LoanIDOpt);
+ }
+ return ExplainMatchResult(UnorderedElementsAreArray(ExpectedExpiredLoans),
+ ActualExpiredLoans, result_listener);
+}
+
+// Base test fixture to manage the runner and helper.
+class LifetimeAnalysisTest : public ::testing::Test {
+protected:
+ void SetupTest(llvm::StringRef Code) {
+ Runner = std::make_unique<LifetimeTestRunner>(Code);
+ Helper = std::make_unique<LifetimeTestHelper>(*Runner);
+ }
+
+ OriginInfo Origin(llvm::StringRef OriginVar) {
+ return OriginInfo(OriginVar, *Helper);
+ }
+
+ /// Factory function that hides the std::vector creation.
+ LoanSetInfo LoansTo(std::initializer_list<std::string> LoanVars) {
+ return LoanSetInfo({LoanVars}, *Helper);
+ }
+
+ /// A convenience helper for asserting that no loans are expired.
+ LoanSetInfo NoLoans() { return LoansTo({}); }
+
+ // Factory function that hides the std::vector creation.
+ auto HasLoansTo(std::initializer_list<std::string> LoanVars,
+ const char *Annotation) {
+ return HasLoansToImpl(std::vector<std::string>(LoanVars), Annotation);
+ }
+
+ std::unique_ptr<LifetimeTestRunner> Runner;
+ std::unique_ptr<LifetimeTestHelper> Helper;
+};
+
+// ========================================================================= //
+// TESTS
+// ========================================================================= //
+
+TEST_F(LifetimeAnalysisTest, SimpleLoanAndOrigin) {
+ SetupTest(R"(
+ void target() {
+ int x;
+ int* p = &x;
+ POINT(p1);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"x"}, "p1"));
+}
+
+TEST_F(LifetimeAnalysisTest, OverwriteOrigin) {
+ SetupTest(R"(
+ void target() {
+ MyObj s1, s2;
+
+ MyObj* p = &s1;
+ POINT(after_s1);
+
+ p = &s2;
+ POINT(after_s2);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1"}, "after_s1"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s2"}, "after_s2"));
+}
+
+TEST_F(LifetimeAnalysisTest, ConditionalLoan) {
+ SetupTest(R"(
+ void target(bool cond) {
+ int a, b;
+ int *p = nullptr;
+ if (cond) {
+ p = &a;
+ POINT(after_then);
+ } else {
+ p = &b;
+ POINT(after_else);
+ }
+ POINT(after_if);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"a"}, "after_then"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"b"}, "after_else"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"a", "b"}, "after_if"));
+}
+
+TEST_F(LifetimeAnalysisTest, PointerChain) {
+ SetupTest(R"(
+ void target() {
+ MyObj y;
+ MyObj* ptr1 = &y;
+ POINT(p1);
+
+ MyObj* ptr2 = ptr1;
+ POINT(p2);
+
+ ptr2 = ptr1;
+ POINT(p3);
+
+ ptr2 = ptr2; // Self assignment
+ POINT(p4);
+ }
+ )");
+ EXPECT_THAT(Origin("ptr1"), HasLoansTo({"y"}, "p1"));
+ EXPECT_THAT(Origin("ptr2"), HasLoansTo({"y"}, "p2"));
+ EXPECT_THAT(Origin("ptr2"), HasLoansTo({"y"}, "p3"));
+ EXPECT_THAT(Origin("ptr2"), HasLoansTo({"y"}, "p4"));
+}
+
+TEST_F(LifetimeAnalysisTest, ReassignToNull) {
+ SetupTest(R"(
+ void target() {
+ MyObj s1;
+ MyObj* p = &s1;
+ POINT(before_null);
+ p = nullptr;
+ POINT(after_null);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1"}, "before_null"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({}, "after_null"));
+}
+
+TEST_F(LifetimeAnalysisTest, ReassignInIf) {
+ SetupTest(R"(
+ void target(bool condition) {
+ MyObj s1, s2;
+ MyObj* p = &s1;
+ POINT(before_if);
+ if (condition) {
+ p = &s2;
+ POINT(after_reassign);
+ }
+ POINT(after_if);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1"}, "before_if"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s2"}, "after_reassign"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1", "s2"}, "after_if"));
+}
+
+TEST_F(LifetimeAnalysisTest, AssignInSwitch) {
+ SetupTest(R"(
+ void target(int mode) {
+ MyObj s1, s2, s3;
+ MyObj* p = nullptr;
+ switch (mode) {
+ case 1:
+ p = &s1;
+ POINT(case1);
+ break;
+ case 2:
+ p = &s2;
+ POINT(case2);
+ break;
+ default:
+ p = &s3;
+ POINT(case3);
+ break;
+ }
+ POINT(after_switch);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1"}, "case1"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s2"}, "case2"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s3"}, "case3"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1", "s2", "s3"}, "after_switch"));
+}
+
+TEST_F(LifetimeAnalysisTest, LoanInLoop) {
+ SetupTest(R"(
+ void target(bool condition) {
+ MyObj* p = nullptr;
+ while (condition) {
+ POINT(start_loop);
+ MyObj inner;
+ p = &inner;
+ POINT(end_loop);
+ }
+ POINT(after_loop);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"inner"}, "start_loop"));
+ EXPECT_THAT(LoansTo({"inner"}), AreExpiredAt("start_loop"));
+
+ EXPECT_THAT(Origin("p"), HasLoansTo({"inner"}, "end_loop"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("end_loop"));
+
+ EXPECT_THAT(Origin("p"), HasLoansTo({"inner"}, "after_loop"));
+ EXPECT_THAT(LoansTo({"inner"}), AreExpiredAt("after_loop"));
+}
+
+TEST_F(LifetimeAnalysisTest, LoopWithBreak) {
+ SetupTest(R"(
+ void target(int count) {
+ MyObj s1;
+ MyObj s2;
+ MyObj* p = &s1;
+ POINT(before_loop);
+ for (int i = 0; i < count; ++i) {
+ if (i == 5) {
+ p = &s2;
+ POINT(inside_if);
+ break;
+ }
+ POINT(after_if);
+ }
+ POINT(after_loop);
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1"}, "before_loop"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s2"}, "inside_if"));
+ // At the join point after if, s2 cannot make it to p without the if.
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1"}, "after_if"));
+ // At the join point after the loop, p could hold a loan to s1 (if the loop
+ // completed normally) or to s2 (if the loop was broken).
+ EXPECT_THAT(Origin("p"), HasLoansTo({"s1", "s2"}, "after_loop"));
+}
+
+TEST_F(LifetimeAnalysisTest, PointersInACycle) {
+ SetupTest(R"(
+ void target(bool condition) {
+ MyObj v1, v2, v3;
+ MyObj *p1 = &v1, *p2 = &v2, *p3 = &v3;
+
+ POINT(before_while);
+ while (condition) {
+ MyObj* temp = p1;
+ p1 = p2;
+ p2 = p3;
+ p3 = temp;
+ }
+ POINT(after_loop);
+ }
+ )");
+ EXPECT_THAT(Origin("p1"), HasLoansTo({"v1"}, "before_while"));
+ EXPECT_THAT(Origin("p2"), HasLoansTo({"v2"}, "before_while"));
+ EXPECT_THAT(Origin("p3"), HasLoansTo({"v3"}, "before_while"));
+
+ // At the fixed point after the loop, all pointers could point to any of
+ // the three variables.
+ EXPECT_THAT(Origin("p1"), HasLoansTo({"v1", "v2", "v3"}, "after_loop"));
+ EXPECT_THAT(Origin("p2"), HasLoansTo({"v1", "v2", "v3"}, "after_loop"));
+ EXPECT_THAT(Origin("p3"), HasLoansTo({"v1", "v2", "v3"}, "after_loop"));
+ EXPECT_THAT(Origin("temp"), HasLoansTo({"v1", "v2", "v3"}, "after_loop"));
+}
+
+TEST_F(LifetimeAnalysisTest, PointersAndExpirationInACycle) {
+ SetupTest(R"(
+ void target(bool condition) {
+ MyObj v1, v2;
+ MyObj *p1 = &v1, *p2 = &v2;
+
+ POINT(before_while);
+ while (condition) {
+ POINT(in_loop_before_temp);
+ MyObj temp;
+ p1 = &temp;
+ POINT(in_loop_after_temp);
+
+ MyObj* q = p1;
+ p1 = p2;
+ p2 = q;
+ }
+ POINT(after_loop);
+ }
+ )");
+ EXPECT_THAT(Origin("p1"), HasLoansTo({"v1"}, "before_while"));
+ EXPECT_THAT(Origin("p2"), HasLoansTo({"v2"}, "before_while"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("before_while"));
+
+ EXPECT_THAT(Origin("p1"),
+ HasLoansTo({"v1", "v2", "temp"}, "in_loop_before_temp"));
+ EXPECT_THAT(Origin("p2"), HasLoansTo({"v2", "temp"}, "in_loop_before_temp"));
+ EXPECT_THAT(LoansTo({"temp"}), AreExpiredAt("in_loop_before_temp"));
+
+ EXPECT_THAT(Origin("p1"), HasLoansTo({"temp"}, "in_loop_after_temp"));
+ EXPECT_THAT(Origin("p2"), HasLoansTo({"v2", "temp"}, "in_loop_after_temp"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("in_loop_after_temp"));
+
+ EXPECT_THAT(Origin("p1"), HasLoansTo({"v1", "v2", "temp"}, "after_loop"));
+ EXPECT_THAT(Origin("p2"), HasLoansTo({"v2", "temp"}, "after_loop"));
+ EXPECT_THAT(LoansTo({"temp"}), AreExpiredAt("after_loop"));
+}
+
+TEST_F(LifetimeAnalysisTest, NestedScopes) {
+ SetupTest(R"(
+ void target() {
+ MyObj* p = nullptr;
+ {
+ MyObj outer;
+ p = &outer;
+ POINT(before_inner_scope);
+ {
+ MyObj inner;
+ p = &inner;
+ POINT(inside_inner_scope);
+ } // inner expires
+ POINT(after_inner_scope);
+ } // outer expires
+ }
+ )");
+ EXPECT_THAT(Origin("p"), HasLoansTo({"outer"}, "before_inner_scope"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"inner"}, "inside_inner_scope"));
+ EXPECT_THAT(Origin("p"), HasLoansTo({"inner"}, "after_inner_scope"));
+}
+
+TEST_F(LifetimeAnalysisTest, SimpleExpiry) {
+ SetupTest(R"(
+ void target() {
+ MyObj* p = nullptr;
+ {
+ MyObj s;
+ p = &s;
+ POINT(before_expiry);
+ } // s goes out of scope here
+ POINT(after_expiry);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("before_expiry"));
+ EXPECT_THAT(LoansTo({"s"}), AreExpiredAt("after_expiry"));
+}
+
+TEST_F(LifetimeAnalysisTest, NestedExpiry) {
+ SetupTest(R"(
+ void target() {
+ MyObj s1;
+ MyObj* p = &s1;
+ POINT(before_inner);
+ {
+ MyObj s2;
+ p = &s2;
+ POINT(in_inner);
+ } // s2 expires
+ POINT(after_inner);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("before_inner"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("in_inner"));
+ EXPECT_THAT(LoansTo({"s2"}), AreExpiredAt("after_inner"));
+}
+
+TEST_F(LifetimeAnalysisTest, ConditionalExpiry) {
+ SetupTest(R"(
+ void target(bool cond) {
+ MyObj s1;
+ MyObj* p = &s1;
+ POINT(before_if);
+ if (cond) {
+ MyObj s2;
+ p = &s2;
+ POINT(then_block);
+ } // s2 expires here
+ POINT(after_if);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("before_if"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("then_block"));
+ EXPECT_THAT(LoansTo({"s2"}), AreExpiredAt("after_if"));
+}
+
+TEST_F(LifetimeAnalysisTest, LoopExpiry) {
+ SetupTest(R"(
+ void target() {
+ MyObj *p = nullptr;
+ for (int i = 0; i < 2; ++i) {
+ POINT(start_loop);
+ MyObj s;
+ p = &s;
+ POINT(end_loop);
+ } // s expires here on each iteration
+ POINT(after_loop);
+ }
+ )");
+ EXPECT_THAT(LoansTo({"s"}), AreExpiredAt("start_loop"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("end_loop"));
+ EXPECT_THAT(LoansTo({"s"}), AreExpiredAt("after_loop"));
+}
+
+TEST_F(LifetimeAnalysisTest, MultipleExpiredLoans) {
+ SetupTest(R"(
+ void target() {
+ MyObj *p1, *p2, *p3;
+ {
+ MyObj s1;
+ p1 = &s1;
+ POINT(p1);
+ } // s1 expires
+ POINT(p2);
+ {
+ MyObj s2;
+ p2 = &s2;
+ MyObj s3;
+ p3 = &s3;
+ POINT(p3);
+ } // s2, s3 expire
+ POINT(p4);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("p1"));
+ EXPECT_THAT(LoansTo({"s1"}), AreExpiredAt("p2"));
+ EXPECT_THAT(LoansTo({"s1"}), AreExpiredAt("p3"));
+ EXPECT_THAT(LoansTo({"s1", "s2", "s3"}), AreExpiredAt("p4"));
+}
+
+TEST_F(LifetimeAnalysisTest, GotoJumpsOutOfScope) {
+ SetupTest(R"(
+ void target(bool cond) {
+ MyObj *p = nullptr;
+ {
+ MyObj s;
+ p = &s;
+ POINT(before_goto);
+ if (cond) {
+ goto end;
+ }
+ } // `s` expires here on the path that doesn't jump
+ POINT(after_scope);
+ end:
+ POINT(after_goto);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("before_goto"));
+ EXPECT_THAT(LoansTo({"s"}), AreExpiredAt("after_scope"));
+ EXPECT_THAT(LoansTo({"s"}), AreExpiredAt("after_goto"));
+}
+
+TEST_F(LifetimeAnalysisTest, ContinueInLoop) {
+ SetupTest(R"(
+ void target(int count) {
+ MyObj *p = nullptr;
+ MyObj outer;
+ p = &outer;
+ POINT(before_loop);
+
+ for (int i = 0; i < count; ++i) {
+ if (i % 2 == 0) {
+ MyObj s_even;
+ p = &s_even;
+ POINT(in_even_iter);
+ continue;
+ }
+ MyObj s_odd;
+ p = &s_odd;
+ POINT(in_odd_iter);
+ }
+ POINT(after_loop);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("before_loop"));
+ EXPECT_THAT(LoansTo({"s_odd"}), AreExpiredAt("in_even_iter"));
+ EXPECT_THAT(LoansTo({"s_even"}), AreExpiredAt("in_odd_iter"));
+ EXPECT_THAT(LoansTo({"s_even", "s_odd"}), AreExpiredAt("after_loop"));
+}
+
+TEST_F(LifetimeAnalysisTest, ReassignedPointerThenOriginalExpires) {
+ SetupTest(R"(
+ void target() {
+ MyObj* p = nullptr;
+ {
+ MyObj s1;
+ p = &s1;
+ POINT(p_has_s1);
+ {
+ MyObj s2;
+ p = &s2;
+ POINT(p_has_s2);
+ }
+ POINT(p_after_s2_expires);
+ } // s1 expires here.
+ POINT(p_after_s1_expires);
+ }
+ )");
+ EXPECT_THAT(NoLoans(), AreExpiredAt("p_has_s1"));
+ EXPECT_THAT(NoLoans(), AreExpiredAt("p_has_s2"));
+ EXPECT_THAT(LoansTo({"s2"}), AreExpiredAt("p_after_s2_expires"));
+ EXPECT_THAT(LoansTo({"s1", "s2"}), AreExpiredAt("p_after_s1_expires"));
+}
+
+} // anonymous namespace
+} // namespace clang::lifetimes::internal
diff --git a/clang/unittests/Analysis/MacroExpansionContextTest.cpp b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
index 9874ea6..25a76ed 100644
--- a/clang/unittests/Analysis/MacroExpansionContextTest.cpp
+++ b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
@@ -33,10 +33,10 @@ namespace {
class MacroExpansionContextTest : public ::testing::Test {
protected:
MacroExpansionContextTest()
- : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
+ : InMemoryFileSystem(
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
FileMgr(FileSystemOptions(), InMemoryFileSystem),
- DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions()) {
TargetOpts->Triple = "x86_64-pc-linux-unknown";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -45,7 +45,6 @@ protected:
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Analysis/UnsafeBufferUsageTest.cpp b/clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
index 9da2c58..f795918 100644
--- a/clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
+++ b/clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
@@ -12,13 +12,12 @@ namespace {
class UnsafeBufferUsageTest : public ::testing::Test {
protected:
UnsafeBufferUsageTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr) {}
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
@@ -58,4 +57,4 @@ TEST_F(UnsafeBufferUsageTest, FixItHintsConflict) {
Fixes = {H1, H2, H3, MkDummyHint(2, 23) /* overlaps H1, H2, and H3 */};
EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
-} \ No newline at end of file
+}
diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp
index b0a034e..4b3af00 100644
--- a/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/clang/unittests/Basic/DiagnosticTest.cpp
@@ -47,7 +47,7 @@ using testing::IsEmpty;
// Check that DiagnosticErrorTrap works with SuppressAllDiagnostics.
TEST(DiagnosticTest, suppressAndTrap) {
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs(), DiagOpts,
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
new IgnoringDiagConsumer());
Diags.setSuppressAllDiagnostics(true);
@@ -78,7 +78,7 @@ TEST(DiagnosticTest, suppressAndTrap) {
TEST(DiagnosticTest, fatalsAsError) {
for (unsigned FatalsAsError = 0; FatalsAsError != 2; ++FatalsAsError) {
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs(), DiagOpts,
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
new IgnoringDiagConsumer());
Diags.setFatalsAsError(FatalsAsError);
@@ -102,7 +102,7 @@ TEST(DiagnosticTest, fatalsAsError) {
TEST(DiagnosticTest, tooManyErrorsIsAlwaysFatal) {
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs(), DiagOpts,
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
new IgnoringDiagConsumer());
Diags.setFatalsAsError(true);
@@ -119,7 +119,7 @@ TEST(DiagnosticTest, tooManyErrorsIsAlwaysFatal) {
// Check that soft RESET works as intended
TEST(DiagnosticTest, softReset) {
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs(), DiagOpts,
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
new IgnoringDiagConsumer());
unsigned numWarnings = 0U, numErrors = 0U;
@@ -143,7 +143,7 @@ TEST(DiagnosticTest, softReset) {
TEST(DiagnosticTest, diagnosticError) {
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs(), DiagOpts,
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
new IgnoringDiagConsumer());
PartialDiagnostic::DiagStorageAllocator Alloc;
llvm::Expected<std::pair<int, int>> Value = DiagnosticError::create(
@@ -166,7 +166,7 @@ TEST(DiagnosticTest, diagnosticError) {
TEST(DiagnosticTest, storedDiagEmptyWarning) {
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs(), DiagOpts);
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts);
class CaptureDiagnosticConsumer : public DiagnosticConsumer {
public:
@@ -197,7 +197,7 @@ protected:
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags{new DiagnosticIDs(), DiagOpts};
+ DiagnosticsEngine Diags{DiagnosticIDs::create(), DiagOpts};
llvm::ArrayRef<StoredDiagnostic> diags() {
return CaptureConsumer.StoredDiags;
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp
index 88d778f..7b3e8bc 100644
--- a/clang/unittests/Basic/FileManagerTest.cpp
+++ b/clang/unittests/Basic/FileManagerTest.cpp
@@ -454,8 +454,7 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
: StringRef("/");
llvm::sys::path::append(CustomWorkingDir, "some", "weird", "path");
- auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
// setCurrentworkingdirectory must finish without error.
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
@@ -475,8 +474,7 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) {
SmallString<64> CustomWorkingDir = getSystemRoot();
- auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
// setCurrentworkingdirectory must finish without error.
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
@@ -501,8 +499,7 @@ TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) {
TEST_F(FileManagerTest, getFileDontOpenRealPath) {
SmallString<64> CustomWorkingDir = getSystemRoot();
- auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
// setCurrentworkingdirectory must finish without error.
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
@@ -533,8 +530,7 @@ TEST_F(FileManagerTest, getBypassFile) {
CustomWorkingDir = "/";
#endif
- auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
// setCurrentworkingdirectory must finish without error.
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
diff --git a/clang/unittests/Basic/SarifTest.cpp b/clang/unittests/Basic/SarifTest.cpp
index ad9f8ec..089b6cb 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -41,15 +41,14 @@ static std::string serializeSarifDocument(llvm::json::Object &&Doc) {
class SarifDocumentWriterTest : public ::testing::Test {
protected:
SarifDocumentWriterTest()
- : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
+ : InMemoryFileSystem(
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
FileMgr(FileSystemOptions(), InMemoryFileSystem),
- DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr) {}
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp
index cbe047b..04b23dd 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -40,8 +40,8 @@ namespace {
class SourceManagerTest : public ::testing::Test {
protected:
SourceManagerTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -49,7 +49,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/CodeGen/TestCompiler.h b/clang/unittests/CodeGen/TestCompiler.h
index a6fec7f..f6fada5 100644
--- a/clang/unittests/CodeGen/TestCompiler.h
+++ b/clang/unittests/CodeGen/TestCompiler.h
@@ -58,7 +58,7 @@ struct TestCompiler {
CG.reset(CreateLLVMCodeGen(
compiler.getDiagnostics(), "main-module",
- &compiler.getVirtualFileSystem(), compiler.getHeaderSearchOpts(),
+ compiler.getVirtualFileSystemPtr(), compiler.getHeaderSearchOpts(),
compiler.getPreprocessorOpts(), compiler.getCodeGenOpts(), Context));
}
diff --git a/clang/unittests/Driver/DXCModeTest.cpp b/clang/unittests/Driver/DXCModeTest.cpp
index f684593..e7d8137 100644
--- a/clang/unittests/Driver/DXCModeTest.cpp
+++ b/clang/unittests/Driver/DXCModeTest.cpp
@@ -55,17 +55,15 @@ static void validateTargetProfile(
}
TEST(DxcModeTest, TargetProfileValidation) {
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
-
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
InMemoryFileSystem->addFile("foo.hlsl", 0,
llvm::MemoryBuffer::getMemBuffer("\n"));
auto *DiagConsumer = new SimpleDiagnosticConsumer;
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer);
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts, DiagConsumer);
validateTargetProfile("-Tvs_6_0", "dxilv1.0--shadermodel6.0-vertex",
InMemoryFileSystem, Diags);
@@ -105,17 +103,15 @@ TEST(DxcModeTest, TargetProfileValidation) {
}
TEST(DxcModeTest, ValidatorVersionValidation) {
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
-
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
InMemoryFileSystem->addFile("foo.hlsl", 0,
llvm::MemoryBuffer::getMemBuffer("\n"));
auto *DiagConsumer = new SimpleDiagnosticConsumer;
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer);
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts, DiagConsumer);
Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
{"clang", "--driver-mode=dxc", "-Tlib_6_7", "foo.hlsl"}));
@@ -210,8 +206,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
}
TEST(DxcModeTest, DefaultEntry) {
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
InMemoryFileSystem->addFile("foo.hlsl", 0,
llvm::MemoryBuffer::getMemBuffer("\n"));
diff --git a/clang/unittests/Driver/SanitizerArgsTest.cpp b/clang/unittests/Driver/SanitizerArgsTest.cpp
index b8bfc68..7847947 100644
--- a/clang/unittests/Driver/SanitizerArgsTest.cpp
+++ b/clang/unittests/Driver/SanitizerArgsTest.cpp
@@ -53,7 +53,7 @@ protected:
assert(!DriverInstance && "Running twice is not allowed");
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diags(new DiagnosticIDs, DiagOpts,
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
new TextDiagnosticPrinter(llvm::errs(), DiagOpts));
DriverInstance.emplace(ClangBinary, "x86_64-unknown-linux-gnu", Diags,
"clang LLVM compiler", prepareFS(ExtraFiles));
@@ -78,8 +78,7 @@ protected:
private:
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>
prepareFS(llvm::ArrayRef<std::string> ExtraFiles) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
- new llvm::vfs::InMemoryFileSystem;
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FS->addFile(ClangBinary, time_t(), llvm::MemoryBuffer::getMemBuffer(""));
FS->addFile(InputFile, time_t(), llvm::MemoryBuffer::getMemBuffer(""));
for (llvm::StringRef F : ExtraFiles)
diff --git a/clang/unittests/Driver/SimpleDiagnosticConsumer.h b/clang/unittests/Driver/SimpleDiagnosticConsumer.h
index c3772ba..7ab409b 100644
--- a/clang/unittests/Driver/SimpleDiagnosticConsumer.h
+++ b/clang/unittests/Driver/SimpleDiagnosticConsumer.h
@@ -42,13 +42,12 @@ struct SimpleDiagnosticConsumer : public clang::DiagnosticConsumer {
// for testing situations where it will only ever be used for emitting
// diagnostics, such as being passed to `MultilibSet::select`.
inline clang::driver::Driver diagnostic_test_driver() {
- llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> DiagID(
- new clang::DiagnosticIDs());
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
auto *DiagConsumer = new SimpleDiagnosticConsumer;
clang::DiagnosticOptions DiagOpts;
- clang::DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer);
+ clang::DiagnosticsEngine Diags(clang::DiagnosticIDs::create(), DiagOpts,
+ DiagConsumer);
return clang::driver::Driver("/bin/clang", "", Diags, "", InMemoryFileSystem);
}
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index 670090a..4fa2729 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -40,10 +40,10 @@ namespace {
TEST(ToolChainTest, VFSGCCInstallation) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
const char *EmptyFiles[] = {
"foo.cpp",
@@ -137,11 +137,11 @@ TEST(ToolChainTest, VFSGCCInstallation) {
TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
"clang LLVM compiler", InMemoryFileSystem);
@@ -176,10 +176,10 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
const char *EmptyFiles[] = {
// Sort entries so the latest version doesn't come first.
@@ -340,10 +340,10 @@ MATCHER_P(jobHasArgs, Substr, "") {
TEST(ToolChainTest, VFSGnuLibcxxPathNoSysroot) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
const char *EmptyFiles[] = {
"foo.cpp",
@@ -371,11 +371,11 @@ TEST(ToolChainTest, VFSGnuLibcxxPathNoSysroot) {
TEST(ToolChainTest, DefaultDriverMode) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
"clang LLVM compiler", InMemoryFileSystem);
@@ -402,7 +402,7 @@ TEST(ToolChainTest, DefaultDriverMode) {
EXPECT_TRUE(CLDriver.IsCLMode());
}
TEST(ToolChainTest, InvalidArgument) {
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
@@ -517,11 +517,11 @@ TEST(ToolChainTest, GetTargetAndMode) {
TEST(ToolChainTest, CommandOutput) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
"clang LLVM compiler", InMemoryFileSystem);
@@ -545,11 +545,11 @@ TEST(ToolChainTest, CommandOutput) {
TEST(ToolChainTest, PostCallback) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
// The executable path must not exist.
Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
@@ -598,11 +598,11 @@ TEST(ToolChainTest, UEFICallingConventionTest) {
TEST(ToolChainTest, UEFIDefaultDebugFormatTest) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
Driver CCDriver("/home/test/bin/clang", "x86_64-unknown-uefi", Diags,
"clang LLVM compiler", InMemoryFileSystem);
CCDriver.setCheckInputsExist(false);
@@ -640,11 +640,10 @@ struct SimpleDiagnosticConsumer : public DiagnosticConsumer {
TEST(ToolChainTest, ConfigFileSearch) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
#ifdef _WIN32
const char *TestRoot = "C:\\";
@@ -717,11 +716,11 @@ struct FileSystemWithError : public llvm::vfs::FileSystem {
TEST(ToolChainTest, ConfigFileError) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
new SimpleDiagnosticConsumer());
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS(new FileSystemWithError);
+ auto FS = llvm::makeIntrusiveRefCnt<FileSystemWithError>();
Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
"clang LLVM compiler", FS);
@@ -738,12 +737,11 @@ TEST(ToolChainTest, ConfigFileError) {
TEST(ToolChainTest, BadConfigFile) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
new SimpleDiagnosticConsumer());
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
#ifdef _WIN32
const char *TestRoot = "C:\\";
@@ -812,12 +810,11 @@ TEST(ToolChainTest, BadConfigFile) {
TEST(ToolChainTest, ConfigInexistentInclude) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
new SimpleDiagnosticConsumer());
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
#ifdef _WIN32
const char *TestRoot = "C:\\";
@@ -853,12 +850,11 @@ TEST(ToolChainTest, ConfigInexistentInclude) {
TEST(ToolChainTest, ConfigRecursiveInclude) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
new SimpleDiagnosticConsumer());
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
#ifdef _WIN32
const char *TestRoot = "C:\\";
@@ -899,11 +895,10 @@ TEST(ToolChainTest, ConfigRecursiveInclude) {
TEST(ToolChainTest, NestedConfigFile) {
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
- new llvm::vfs::InMemoryFileSystem);
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
#ifdef _WIN32
const char *TestRoot = "C:\\";
diff --git a/clang/unittests/Format/BracesInserterTest.cpp b/clang/unittests/Format/BracesInserterTest.cpp
index e0c447d..572e53e 100644
--- a/clang/unittests/Format/BracesInserterTest.cpp
+++ b/clang/unittests/Format/BracesInserterTest.cpp
@@ -257,9 +257,9 @@ TEST_F(BracesInserterTest, InsertBracesRange) {
FormatStyle Style = getLLVMStyle();
Style.InsertBraces = true;
- const StringRef Code("while (a)\n"
- " if (b)\n"
- " return;");
+ constexpr StringRef Code("while (a)\n"
+ " if (b)\n"
+ " return;");
verifyFormat("while (a) {\n"
" if (b)\n"
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 65d8b36..9de3cca 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -249,6 +249,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions,
AfterFunctionDefinitionName);
CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);
+ CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterNot);
CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);
CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterPlacementOperator);
CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0bc1c6d..9c5aa11 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3185,7 +3185,7 @@ TEST_F(FormatTest, FormatsLabels) {
// The opening brace may either be on the same unwrapped line as the colon or
// on a separate one. The formatter should recognize both.
Style = getLLVMStyle();
- Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Allman;
+ Style.BreakBeforeBraces = FormatStyle::BS_Allman;
verifyFormat("{\n"
" some_code();\n"
"test_label:\n"
@@ -3206,7 +3206,7 @@ TEST_F(FormatTest, FormatsLabels) {
TEST_F(FormatTest, MultiLineControlStatements) {
FormatStyle Style = getLLVMStyleWithColumns(20);
- Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
// Short lines should keep opening brace on same line.
verifyFormat("if (foo) {\n"
@@ -3441,7 +3441,7 @@ TEST_F(FormatTest, MultiLineControlStatements) {
TEST_F(FormatTest, BeforeWhile) {
FormatStyle Style = getLLVMStyle();
- Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
verifyFormat("do {\n"
" foo();\n"
@@ -4803,12 +4803,13 @@ TEST_F(FormatTest, FormatsInlineASM) {
"int i;");
auto Style = getLLVMStyleWithColumns(0);
- const StringRef Code1{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));"};
- const StringRef Code2{"asm(\"xyz\"\n"
- " : \"=a\"(a), \"=d\"(b)\n"
- " : \"a\"(data));"};
- const StringRef Code3{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
- " : \"a\"(data));"};
+ constexpr StringRef Code1(
+ "asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
+ constexpr StringRef Code2("asm(\"xyz\"\n"
+ " : \"=a\"(a), \"=d\"(b)\n"
+ " : \"a\"(data));");
+ constexpr StringRef Code3("asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+ " : \"a\"(data));");
Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
verifyFormat(Code1, Style);
@@ -6681,6 +6682,17 @@ TEST_F(FormatTest, EscapedNewlines) {
" int x(int a);",
AlignLeft);
+ // Escaped with a trigraph. The program just has to avoid crashing.
+ verifyNoCrash("#define A \?\?/\n"
+ "int i;\?\?/\n"
+ " int j;");
+ verifyNoCrash("#define A \?\?/\r\n"
+ "int i;\?\?/\r\n"
+ " int j;");
+ verifyNoCrash("#define A \?\?/\n"
+ "int i;",
+ getGoogleStyle(FormatStyle::LK_CSharp));
+
// CRLF line endings
verifyFormat("#define A \\\r\n int i; \\\r\n int j;",
"#define A \\\r\nint i;\\\r\n int j;", Narrow);
@@ -6693,16 +6705,16 @@ TEST_F(FormatTest, EscapedNewlines) {
" int x(int a);",
AlignLeft);
- constexpr StringRef Code{"#define A \\\n"
+ constexpr StringRef Code("#define A \\\n"
" int a123; \\\n"
" int a; \\\n"
- " int a1234;"};
+ " int a1234;");
verifyFormat(Code, AlignLeft);
- constexpr StringRef Code2{"#define A \\\n"
+ constexpr StringRef Code2("#define A \\\n"
" int a123; \\\n"
" int a; \\\n"
- " int a1234;"};
+ " int a1234;");
auto LastLine = getLLVMStyle();
LastLine.AlignEscapedNewlines = FormatStyle::ENAS_LeftWithLastLine;
verifyFormat(Code2, LastLine);
@@ -7771,6 +7783,16 @@ TEST_F(FormatTest, ConstructorInitializers) {
"Constructor() :\n"
" // Comment forcing unwanted break.\n"
" aaaa(aaaa) {}");
+
+ // Braced initializers with trailing commas.
+ verifyFormat("MyClass::MyClass()\n"
+ " : aaaa{\n"
+ " 0,\n"
+ " },\n"
+ " bbbb{\n"
+ " 0,\n"
+ " } {}",
+ "MyClass::MyClass():aaaa{0,},bbbb{0,}{}");
}
TEST_F(FormatTest, AllowAllConstructorInitializersOnNextLine) {
@@ -8571,10 +8593,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
"operator<<(const SomeLooooooooooooooooooooooooogType &other);");
verifyGoogleFormat(
"SomeLoooooooooooooooooooooooooooooogType operator>>(\n"
- " const SomeLooooooooogType &a, const SomeLooooooooogType &b);");
+ " const SomeLooooooooogType& a, const SomeLooooooooogType& b);");
verifyGoogleFormat(
"SomeLoooooooooooooooooooooooooooooogType operator<<(\n"
- " const SomeLooooooooogType &a, const SomeLooooooooogType &b);");
+ " const SomeLooooooooogType& a, const SomeLooooooooogType& b);");
verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1);");
@@ -8583,7 +8605,7 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
verifyGoogleFormat(
"typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa\n"
"aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
- " bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}");
+ " bool* aaaaaaaaaaaaaaaaaa, bool* aa) {}");
verifyGoogleFormat("template <typename T>\n"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
"aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa(\n"
@@ -12091,15 +12113,22 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
Prefix = "void a() const &;\n"
"void b() const &;\n";
verifyFormat(Prefix + "int *x;", Prefix + "int* x;", DerivePointerAlignment);
+
+ constexpr StringRef Code("MACRO(int*, std::function<void() &&>);");
+ verifyFormat(Code, DerivePointerAlignment);
+
+ auto Style = getGoogleStyle();
+ Style.DerivePointerAlignment = true;
+ verifyFormat(Code, Style);
}
TEST_F(FormatTest, PointerAlignmentFallback) {
FormatStyle Style = getLLVMStyle();
Style.DerivePointerAlignment = true;
- const StringRef Code("int* p;\n"
- "int *q;\n"
- "int * r;");
+ constexpr StringRef Code("int* p;\n"
+ "int *q;\n"
+ "int * r;");
EXPECT_EQ(Style.PointerAlignment, FormatStyle::PAS_Right);
verifyFormat("int *p;\n"
@@ -12891,27 +12920,31 @@ TEST_F(FormatTest, UnderstandsEllipsis) {
}
TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) {
+ auto Style = getGoogleStyle();
+ EXPECT_FALSE(Style.DerivePointerAlignment);
+ Style.DerivePointerAlignment = true;
+
verifyFormat("int *a;\n"
"int *a;\n"
"int *a;",
"int *a;\n"
"int* a;\n"
"int *a;",
- getGoogleStyle());
+ Style);
verifyFormat("int* a;\n"
"int* a;\n"
"int* a;",
"int* a;\n"
"int* a;\n"
"int *a;",
- getGoogleStyle());
+ Style);
verifyFormat("int *a;\n"
"int *a;\n"
"int *a;",
"int *a;\n"
"int * a;\n"
"int * a;",
- getGoogleStyle());
+ Style);
verifyFormat("auto x = [] {\n"
" int *a;\n"
" int *a;\n"
@@ -12920,7 +12953,7 @@ TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) {
"auto x=[]{int *a;\n"
"int * a;\n"
"int * a;};",
- getGoogleStyle());
+ Style);
}
TEST_F(FormatTest, UnderstandsRvalueReferences) {
@@ -13056,7 +13089,7 @@ TEST_F(FormatTest, FormatsCasts) {
verifyFormat("virtual void foo(char &) const;");
verifyFormat("virtual void foo(int *a, char *) const;");
verifyFormat("int a = sizeof(int *) + b;");
- verifyGoogleFormat("int a = alignof(int *) + b;");
+ verifyGoogleFormat("int a = alignof(int*) + b;");
verifyFormat("bool b = f(g<int>) && c;");
verifyFormat("typedef void (*f)(int i) func;");
verifyFormat("void operator++(int) noexcept;");
@@ -15014,7 +15047,7 @@ TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
" aaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {}");
- constexpr StringRef Code{"void foo() { /* Empty */ }"};
+ constexpr StringRef Code("void foo() { /* Empty */ }");
verifyFormat(Code);
verifyFormat(Code, "void foo() { /* Empty */\n"
"}");
@@ -17652,6 +17685,12 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
verifyFormat("int x = int (y);", SomeSpace2);
verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
+ auto Style = getLLVMStyle();
+ Style.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+ EXPECT_FALSE(Style.SpaceBeforeParensOptions.AfterNot);
+ Style.SpaceBeforeParensOptions.AfterNot = true;
+ verifyFormat("return not (a || b);", Style);
+
FormatStyle SpaceAfterOverloadedOperator = getLLVMStyle();
SpaceAfterOverloadedOperator.SpaceBeforeParens = FormatStyle::SBPO_Custom;
SpaceAfterOverloadedOperator.SpaceBeforeParensOptions
@@ -23779,7 +23818,7 @@ TEST_F(FormatTest, FormatsLambdas) {
LLVMWithBeforeLambdaBody.BreakBeforeBraces = FormatStyle::BS_Custom;
LLVMWithBeforeLambdaBody.BraceWrapping.BeforeLambdaBody = true;
LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
- FormatStyle::ShortLambdaStyle::SLS_None;
+ FormatStyle::SLS_None;
verifyFormat("FctWithOneNestedLambdaInline_SLS_None(\n"
" []()\n"
" {\n"
@@ -23815,7 +23854,7 @@ TEST_F(FormatTest, FormatsLambdas) {
LLVMWithBeforeLambdaBody);
LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
- FormatStyle::ShortLambdaStyle::SLS_Empty;
+ FormatStyle::SLS_Empty;
verifyFormat("FctWithOneNestedLambdaInline_SLS_Empty(\n"
" []()\n"
" {\n"
@@ -23862,7 +23901,7 @@ TEST_F(FormatTest, FormatsLambdas) {
LLVMWithBeforeLambdaBody);
LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
- FormatStyle::ShortLambdaStyle::SLS_Inline;
+ FormatStyle::SLS_Inline;
verifyFormat("FctWithOneNestedLambdaInline_SLS_Inline([]() { return 17; });",
LLVMWithBeforeLambdaBody);
verifyFormat("FctWithOneNestedLambdaEmpty_SLS_Inline([]() {});",
@@ -23893,7 +23932,7 @@ TEST_F(FormatTest, FormatsLambdas) {
LLVMWithBeforeLambdaBody);
LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
- FormatStyle::ShortLambdaStyle::SLS_All;
+ FormatStyle::SLS_All;
verifyFormat("FctWithOneNestedLambdaInline_SLS_All([]() { return 17; });",
LLVMWithBeforeLambdaBody);
verifyFormat("FctWithOneNestedLambdaEmpty_SLS_All([]() {});",
@@ -24025,7 +24064,7 @@ TEST_F(FormatTest, FormatsLambdas) {
LLVMWithBeforeLambdaBody);
LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
- FormatStyle::ShortLambdaStyle::SLS_None;
+ FormatStyle::SLS_None;
verifyFormat("auto select = [this]() -> const Library::Object *\n"
"{\n"
@@ -24273,7 +24312,7 @@ TEST_F(FormatTest, LambdaWithLineComments) {
LLVMWithBeforeLambdaBody.BreakBeforeBraces = FormatStyle::BS_Custom;
LLVMWithBeforeLambdaBody.BraceWrapping.BeforeLambdaBody = true;
LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
- FormatStyle::ShortLambdaStyle::SLS_All;
+ FormatStyle::SLS_All;
verifyFormat("auto k = []() { return; }", LLVMWithBeforeLambdaBody);
verifyFormat("auto k = []() // comment\n"
@@ -25419,7 +25458,7 @@ TEST_F(FormatTest, AtomicQualifier) {
verifyFormat("struct foo {\n"
" int a1;\n"
" _Atomic(a) a2;\n"
- " _Atomic(_Atomic(int) *const) a3;\n"
+ " _Atomic(_Atomic(int)* const) a3;\n"
"};",
Google);
verifyFormat("_Atomic(uint64_t) a;");
@@ -27244,7 +27283,7 @@ TEST_F(FormatTest, IndentAccessModifiers) {
TEST_F(FormatTest, LimitlessStringsAndComments) {
auto Style = getLLVMStyleWithColumns(0);
- constexpr StringRef Code =
+ constexpr StringRef Code(
"/**\n"
" * This is a multiline comment with quite some long lines, at least for "
"the LLVM Style.\n"
@@ -27265,7 +27304,7 @@ TEST_F(FormatTest, LimitlessStringsAndComments) {
" const std::string SmallString = \"Hello World\";\n"
" // Small line comment\n"
" return String.size() > SmallString.size();\n"
- "}";
+ "}");
verifyNoChange(Code, Style);
}
@@ -28371,10 +28410,15 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"Foo &operator-(Foo &);",
Style);
- Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
+ Style.ReferenceAlignment = FormatStyle::RAS_Left;
verifyFormat("[[nodiscard]]\n"
"Foo& operator-(Foo&);",
Style);
+
+ Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+ verifyFormat("[[deprecated]]\n"
+ "void f() = delete;",
+ Style);
}
TEST_F(FormatTest, InsertNewlineAtEOF) {
@@ -28384,9 +28428,9 @@ TEST_F(FormatTest, InsertNewlineAtEOF) {
verifyNoChange("int i;\n", Style);
verifyFormat("int i;\n", "int i;", Style);
- constexpr StringRef Code{"namespace {\n"
+ constexpr StringRef Code("namespace {\n"
"int i;\n"
- "} // namespace"};
+ "} // namespace");
verifyFormat(Code.str() + '\n', Code, Style,
{tooling::Range(19, 13)}); // line 3
}
@@ -28395,7 +28439,7 @@ TEST_F(FormatTest, KeepEmptyLinesAtEOF) {
FormatStyle Style = getLLVMStyle();
Style.KeepEmptyLines.AtEndOfFile = true;
- const StringRef Code{"int i;\n\n"};
+ constexpr StringRef Code("int i;\n\n");
verifyNoChange(Code, Style);
verifyFormat(Code, "int i;\n\n\n", Style);
}
@@ -28628,8 +28672,8 @@ TEST_F(FormatTest, PPDirectivesAndCommentsInBracedInit) {
}
TEST_F(FormatTest, BreakAdjacentStringLiterals) {
- constexpr StringRef Code{
- "return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
+ constexpr StringRef Code(
+ "return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";");
verifyFormat("return \"Code\"\n"
" \"\\0\\52\\26\\55\\55\\0\"\n"
@@ -29040,9 +29084,9 @@ TEST_F(FormatTest, KeepFormFeed) {
auto Style = getLLVMStyle();
Style.KeepFormFeed = true;
- constexpr StringRef NoFormFeed{"int i;\n"
+ constexpr StringRef NoFormFeed("int i;\n"
"\n"
- "void f();"};
+ "void f();");
verifyFormat(NoFormFeed,
"int i;\n"
" \f\n"
@@ -29064,9 +29108,9 @@ TEST_F(FormatTest, KeepFormFeed) {
"void f();\f",
Style);
- constexpr StringRef FormFeed{"int i;\n"
+ constexpr StringRef FormFeed("int i;\n"
"\f\n"
- "void f();"};
+ "void f();");
verifyNoChange(FormFeed, Style);
Style.LineEnding = FormatStyle::LE_LF;
@@ -29076,10 +29120,10 @@ TEST_F(FormatTest, KeepFormFeed) {
"void f();",
Style);
- constexpr StringRef FormFeedBeforeEmptyLine{"int i;\n"
+ constexpr StringRef FormFeedBeforeEmptyLine("int i;\n"
"\f\n"
"\n"
- "void f();"};
+ "void f();");
Style.MaxEmptyLinesToKeep = 2;
verifyFormat(FormFeedBeforeEmptyLine,
"int i;\n"
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 8870755..69026bc 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -1120,11 +1120,11 @@ TEST_F(FormatTestComments, KeepsLevelOfCommentBeforePPDirective) {
" }\n"
"}"));
- const StringRef Code("void func() {\n"
- " // clang-format off\n"
- " #define KV(value) #value, value\n"
- " // clang-format on\n"
- "}");
+ constexpr StringRef Code("void func() {\n"
+ " // clang-format off\n"
+ " #define KV(value) #value, value\n"
+ " // clang-format on\n"
+ "}");
verifyNoChange(Code);
auto Style = getLLVMStyle();
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index ca5aba0..1275564 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -631,17 +631,17 @@ TEST_F(FormatTestJava, SwitchExpression) {
"});",
Style);
- constexpr StringRef Code1{"i = switch (day) {\n"
+ constexpr StringRef Code1("i = switch (day) {\n"
" case THURSDAY, SATURDAY -> 8;\n"
" case WEDNESDAY -> 9;\n"
" default -> 0;\n"
- "};"};
+ "};");
verifyFormat(Code1, Style);
Style.IndentCaseLabels = true;
verifyFormat(Code1, Style);
- constexpr StringRef Code2{"i = switch (day) {\n"
+ constexpr StringRef Code2("i = switch (day) {\n"
" case THURSDAY, SATURDAY -> {\n"
" foo();\n"
" yield 8;\n"
@@ -653,17 +653,17 @@ TEST_F(FormatTestJava, SwitchExpression) {
" default -> {\n"
" yield 0;\n"
" }\n"
- "};"};
+ "};");
verifyFormat(Code2, Style);
Style.IndentCaseLabels = false;
verifyFormat(Code2, Style);
- constexpr StringRef Code3{"switch (day) {\n"
+ constexpr StringRef Code3("switch (day) {\n"
"case THURSDAY, SATURDAY -> i = 8;\n"
"case WEDNESDAY -> i = 9;\n"
"default -> i = 0;\n"
- "};"};
+ "};");
verifyFormat(Code3, Style);
Style.IndentCaseLabels = true;
diff --git a/clang/unittests/Format/FormatTestSelective.cpp b/clang/unittests/Format/FormatTestSelective.cpp
index 0b7ac21..1a01153 100644
--- a/clang/unittests/Format/FormatTestSelective.cpp
+++ b/clang/unittests/Format/FormatTestSelective.cpp
@@ -672,15 +672,14 @@ TEST_F(FormatTestSelective, FormatMacroRegardlessOfPreviousIndent) {
// need to be adapted.
Style = getLLVMStyle();
- const StringRef Code{" class Foo {\n"
- " void test() {\n"
- " #ifdef 1\n"
- " #define some\n" // format this line
- " #endif\n"
- " }};"};
-
- EXPECT_EQ(Style.IndentPPDirectives,
- FormatStyle::PPDirectiveIndentStyle::PPDIS_None);
+ constexpr StringRef Code(" class Foo {\n"
+ " void test() {\n"
+ " #ifdef 1\n"
+ " #define some\n" // format this line
+ " #endif\n"
+ " }};");
+
+ EXPECT_EQ(Style.IndentPPDirectives, FormatStyle::PPDIS_None);
EXPECT_EQ(" class Foo {\n"
" void test() {\n"
" #ifdef 1\n"
@@ -689,8 +688,7 @@ TEST_F(FormatTestSelective, FormatMacroRegardlessOfPreviousIndent) {
" }};", // Ditto: Bug?
format(Code, 57, 0));
- Style.IndentPPDirectives =
- FormatStyle::PPDirectiveIndentStyle::PPDIS_BeforeHash;
+ Style.IndentPPDirectives = FormatStyle::PPDIS_BeforeHash;
EXPECT_EQ(" class Foo {\n"
" void test() {\n"
" #ifdef 1\n"
@@ -699,8 +697,7 @@ TEST_F(FormatTestSelective, FormatMacroRegardlessOfPreviousIndent) {
" }};",
format(Code, 57, 0));
- Style.IndentPPDirectives =
- FormatStyle::PPDirectiveIndentStyle::PPDIS_AfterHash;
+ Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
EXPECT_EQ(" class Foo {\n"
" void test() {\n"
" #ifdef 1\n"
diff --git a/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp b/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
index b1e42e9..53b6dd8 100644
--- a/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
+++ b/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
@@ -24,7 +24,7 @@ TEST_F(IntegerLiteralSeparatorTest, SingleQuoteAsSeparator) {
EXPECT_EQ(Style.IntegerLiteralSeparator.Decimal, 0);
EXPECT_EQ(Style.IntegerLiteralSeparator.Hex, 0);
- const StringRef Binary("b = 0b10011'11'0110'1u;");
+ constexpr StringRef Binary("b = 0b10011'11'0110'1u;");
verifyFormat(Binary, Style);
Style.IntegerLiteralSeparator.Binary = -1;
verifyFormat("b = 0b100111101101u;", Binary, Style);
@@ -33,14 +33,14 @@ TEST_F(IntegerLiteralSeparatorTest, SingleQuoteAsSeparator) {
Style.IntegerLiteralSeparator.Binary = 4;
verifyFormat("b = 0b1001'1110'1101u;", Binary, Style);
- const StringRef Decimal("d = 184467'440737'0'95505'92Ull;");
+ constexpr StringRef Decimal("d = 184467'440737'0'95505'92Ull;");
verifyFormat(Decimal, Style);
Style.IntegerLiteralSeparator.Decimal = -1;
verifyFormat("d = 18446744073709550592Ull;", Decimal, Style);
Style.IntegerLiteralSeparator.Decimal = 3;
verifyFormat("d = 18'446'744'073'709'550'592Ull;", Decimal, Style);
- const StringRef Hex("h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;");
+ constexpr StringRef Hex("h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;");
verifyFormat(Hex, Style);
Style.IntegerLiteralSeparator.Hex = -1;
verifyFormat("h = 0xDEADBEEFDEADBEEFuz;", Hex, Style);
@@ -83,13 +83,16 @@ TEST_F(IntegerLiteralSeparatorTest, SingleQuoteAsSeparator) {
"d = 5678_km;\n"
"h = 0xDEF_u16;",
Style);
+
+ Style.Standard = FormatStyle::LS_Cpp11;
+ verifyFormat("ld = 1234L;", Style);
}
TEST_F(IntegerLiteralSeparatorTest, UnderscoreAsSeparator) {
FormatStyle Style = getLLVMStyle();
- const StringRef Binary("B = 0B10011_11_0110_1;");
- const StringRef Decimal("d = 184467_440737_0_95505_92;");
- const StringRef Hex("H = 0XDEAD_BEEF_DE_AD_BEE_F;");
+ constexpr StringRef Binary("B = 0B10011_11_0110_1;");
+ constexpr StringRef Decimal("d = 184467_440737_0_95505_92;");
+ constexpr StringRef Hex("H = 0XDEAD_BEEF_DE_AD_BEE_F;");
auto TestUnderscore = [&](auto Language) {
Style.Language = Language;
@@ -173,16 +176,16 @@ TEST_F(IntegerLiteralSeparatorTest, FixRanges) {
FormatStyle Style = getLLVMStyle();
Style.IntegerLiteralSeparator.Decimal = 3;
- const StringRef Code("i = -12'34;\n"
- "// clang-format off\n"
- "j = 123'4;\n"
- "// clang-format on\n"
- "k = +1'23'4;");
- const StringRef Expected("i = -1'234;\n"
+ constexpr StringRef Code("i = -12'34;\n"
"// clang-format off\n"
"j = 123'4;\n"
"// clang-format on\n"
- "k = +1'234;");
+ "k = +1'23'4;");
+ constexpr StringRef Expected("i = -1'234;\n"
+ "// clang-format off\n"
+ "j = 123'4;\n"
+ "// clang-format on\n"
+ "k = +1'234;");
verifyFormat(Expected, Code, Style);
diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp
index 5194d65..48ecd5d 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -1084,10 +1084,10 @@ TEST_F(SortIncludesTest, DoNotSortLikelyXml) {
}
TEST_F(SortIncludesTest, DoNotSortCSharp) {
- constexpr StringRef Code{"const string expectedDataStruct = @\"\n"
+ constexpr StringRef Code("const string expectedDataStruct = @\"\n"
" #include <b.h>\n"
" #include <a.h>\n"
- " \";"};
+ " \";");
FmtStyle.Language = FormatStyle::LK_CSharp;
EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cs").empty());
}
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index ce7787e..7f99655 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -618,7 +618,7 @@ TEST_F(TokenAnnotatorTest, UnderstandsStructs) {
EXPECT_TOKEN(Tokens[19], tok::l_brace, TT_StructLBrace);
EXPECT_TOKEN(Tokens[20], tok::r_brace, TT_StructRBrace);
- constexpr StringRef Code{"struct EXPORT StructName {};"};
+ constexpr StringRef Code("struct EXPORT StructName {};");
Tokens = annotate(Code);
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
@@ -3958,7 +3958,7 @@ TEST_F(TokenAnnotatorTest, SplitPenalty) {
}
TEST_F(TokenAnnotatorTest, TemplateName) {
- constexpr StringRef Code{"return Foo < A || B > (C ^ D);"};
+ constexpr StringRef Code("return Foo < A || B > (C ^ D);");
auto Tokens = annotate(Code);
ASSERT_EQ(Tokens.size(), 14u) << Tokens;
diff --git a/clang/unittests/Frontend/ASTUnitTest.cpp b/clang/unittests/Frontend/ASTUnitTest.cpp
index afa64b5..7148ca0 100644
--- a/clang/unittests/Frontend/ASTUnitTest.cpp
+++ b/clang/unittests/Frontend/ASTUnitTest.cpp
@@ -119,8 +119,7 @@ TEST_F(ASTUnitTest, GetBufferForFileMemoryMapping) {
}
TEST_F(ASTUnitTest, ModuleTextualHeader) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFs =
- new llvm::vfs::InMemoryFileSystem();
+ auto InMemoryFs = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
InMemoryFs->addFile("test.cpp", 0, llvm::MemoryBuffer::getMemBuffer(R"cpp(
#include "Textual.h"
void foo() {}
diff --git a/clang/unittests/Frontend/CodeGenActionTest.cpp b/clang/unittests/Frontend/CodeGenActionTest.cpp
index 90818b7..b2792c4 100644
--- a/clang/unittests/Frontend/CodeGenActionTest.cpp
+++ b/clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -76,40 +76,4 @@ TEST(CodeGenTest, CodeGenFromIRMemBuffer) {
bool Success = Compiler.ExecuteAction(Action);
EXPECT_TRUE(Success);
}
-
-TEST(CodeGenTest, DebugInfoCWDCodeGen) {
- // Check that debug info is accessing the current working directory from the
- // VFS instead of calling \p llvm::sys::fs::current_path() directly.
-
- auto Sept = llvm::sys::path::get_separator();
- auto VFS = std::make_unique<llvm::vfs::InMemoryFileSystem>();
- VFS->setCurrentWorkingDirectory(
- std::string(llvm::formatv("{0}in-memory-fs-cwd", Sept)));
- std::string TestPath =
- std::string(llvm::formatv("{0}in-memory-fs-cwd{0}test.cpp", Sept));
- VFS->addFile(TestPath, 0, llvm::MemoryBuffer::getMemBuffer("int x;\n"));
-
- auto Invocation = std::make_shared<CompilerInvocation>();
- Invocation->getFrontendOpts().Inputs.push_back(
- FrontendInputFile("test.cpp", Language::CXX));
- Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
- Invocation->getTargetOpts().Triple = "x86_64-unknown-linux-gnu";
- Invocation->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
- CompilerInstance Compiler(std::move(Invocation));
-
- SmallString<256> IRBuffer;
- Compiler.setOutputStream(std::make_unique<raw_svector_ostream>(IRBuffer));
- Compiler.createDiagnostics(*VFS);
- Compiler.createFileManager(std::move(VFS));
-
- EmitLLVMAction Action;
- bool Success = Compiler.ExecuteAction(Action);
- EXPECT_TRUE(Success);
-
- SmallString<128> RealCWD;
- llvm::sys::fs::current_path(RealCWD);
- EXPECT_TRUE(!RealCWD.empty());
- EXPECT_FALSE(IRBuffer.str().contains(RealCWD));
- EXPECT_TRUE(IRBuffer.str().contains("in-memory-fs-cwd"));
-}
}
diff --git a/clang/unittests/Frontend/CompilerInstanceTest.cpp b/clang/unittests/Frontend/CompilerInstanceTest.cpp
index 459a386..7c1b653 100644
--- a/clang/unittests/Frontend/CompilerInstanceTest.cpp
+++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -71,7 +71,7 @@ TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) {
// Create a minimal CompilerInstance which should use the VFS we specified
// in the CompilerInvocation (as we don't explicitly set our own).
CompilerInstance Instance(std::move(CInvok));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
Instance.createFileManager();
// Check if the virtual file exists which means that our VFS is used by the
@@ -135,7 +135,7 @@ TEST(CompilerInstance, MultipleInputsCleansFileIDs) {
ASSERT_TRUE(CInvok) << "could not create compiler invocation";
CompilerInstance Instance(std::move(CInvok));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
Instance.createFileManager(VFS);
// Run once for `a.cc` and then for `a.h`. This makes sure we get the same
diff --git a/clang/unittests/Frontend/PCHPreambleTest.cpp b/clang/unittests/Frontend/PCHPreambleTest.cpp
index faad408..d27f793 100644
--- a/clang/unittests/Frontend/PCHPreambleTest.cpp
+++ b/clang/unittests/Frontend/PCHPreambleTest.cpp
@@ -62,7 +62,7 @@ public:
void TearDown() override {}
void ResetVFS() {
- VFS = new ReadCountingInMemoryFileSystem();
+ VFS = llvm::makeIntrusiveRefCnt<ReadCountingInMemoryFileSystem>();
// We need the working directory to be set to something absolute,
// otherwise it ends up being inadvertently set to the current
// working directory in the real file system due to a series of
diff --git a/clang/unittests/Frontend/ReparseWorkingDirTest.cpp b/clang/unittests/Frontend/ReparseWorkingDirTest.cpp
index 1b8051f..38ef468 100644
--- a/clang/unittests/Frontend/ReparseWorkingDirTest.cpp
+++ b/clang/unittests/Frontend/ReparseWorkingDirTest.cpp
@@ -28,7 +28,9 @@ class ReparseWorkingDirTest : public ::testing::Test {
std::shared_ptr<PCHContainerOperations> PCHContainerOpts;
public:
- void SetUp() override { VFS = new vfs::InMemoryFileSystem(); }
+ void SetUp() override {
+ VFS = llvm::makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
+ }
void TearDown() override {}
void setWorkingDirectory(StringRef Path) {
diff --git a/clang/unittests/Frontend/SearchPathTest.cpp b/clang/unittests/Frontend/SearchPathTest.cpp
index c74a5c7..a8c16fe 100644
--- a/clang/unittests/Frontend/SearchPathTest.cpp
+++ b/clang/unittests/Frontend/SearchPathTest.cpp
@@ -40,8 +40,8 @@ namespace {
class SearchPathTest : public ::testing::Test {
protected:
SearchPathTest()
- : Diags(new DiagnosticIDs(), DiagOpts, new IgnoringDiagConsumer()),
- VFS(new llvm::vfs::InMemoryFileSystem),
+ : Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
+ VFS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
FileMgr(FileSystemOptions(), VFS), SourceMgr(Diags, FileMgr),
Invocation(std::make_unique<CompilerInvocation>()) {}
diff --git a/clang/unittests/Frontend/TextDiagnosticTest.cpp b/clang/unittests/Frontend/TextDiagnosticTest.cpp
index 8fd8187..622dbc5 100644
--- a/clang/unittests/Frontend/TextDiagnosticTest.cpp
+++ b/clang/unittests/Frontend/TextDiagnosticTest.cpp
@@ -36,9 +36,8 @@ TEST(TextDiagnostic, ShowLine) {
// Create dummy FileManager and SourceManager.
FileSystemOptions FSOpts;
FileManager FileMgr(FSOpts);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs);
DiagnosticOptions DiagEngineOpts;
- DiagnosticsEngine DiagEngine(DiagID, DiagEngineOpts,
+ DiagnosticsEngine DiagEngine(DiagnosticIDs::create(), DiagEngineOpts,
new IgnoringDiagConsumer());
SourceManager SrcMgr(DiagEngine, FileMgr);
diff --git a/clang/unittests/Frontend/UtilsTest.cpp b/clang/unittests/Frontend/UtilsTest.cpp
index cf385a5..fc411e4 100644
--- a/clang/unittests/Frontend/UtilsTest.cpp
+++ b/clang/unittests/Frontend/UtilsTest.cpp
@@ -29,7 +29,7 @@ TEST(BuildCompilerInvocationTest, RecoverMultipleJobs) {
clang::DiagnosticOptions DiagOpts;
CreateInvocationOptions Opts;
Opts.RecoverOnError = true;
- Opts.VFS = new llvm::vfs::InMemoryFileSystem();
+ Opts.VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
Opts.Diags = clang::CompilerInstance::createDiagnostics(*Opts.VFS, DiagOpts,
&D, false);
std::unique_ptr<CompilerInvocation> CI = createInvocation(Args, Opts);
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp
index b97f5ae..768058b 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -22,6 +22,8 @@
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
+#include "llvm/TargetParser/Host.h"
+
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -158,12 +160,12 @@ TEST_F(InterpreterTest, UndoCommand) {
// Fail to undo.
auto Err1 = Interp->Undo();
- EXPECT_EQ("Operation failed. Too many undos",
+ EXPECT_EQ("Operation failed. No input left to undo",
llvm::toString(std::move(Err1)));
auto Err2 = Interp->Parse("int foo = 42;");
EXPECT_TRUE(!!Err2);
auto Err3 = Interp->Undo(2);
- EXPECT_EQ("Operation failed. Too many undos",
+ EXPECT_EQ("Operation failed. Wanted to undo 2 inputs, only have 1.",
llvm::toString(std::move(Err3)));
// Succeed to undo.
@@ -389,6 +391,26 @@ TEST_F(InterpreterTest, Value) {
EXPECT_TRUE(V9.getType()->isMemberFunctionPointerType());
EXPECT_EQ(V9.getKind(), Value::K_PtrOrObj);
EXPECT_TRUE(V9.isManuallyAlloc());
+
+ Value V10;
+ llvm::cantFail(Interp->ParseAndExecute(
+ "enum D : unsigned int {Zero = 0, One}; One", &V10));
+
+ std::string prettyType;
+ llvm::raw_string_ostream OSType(prettyType);
+ V10.printType(OSType);
+ EXPECT_STREQ(prettyType.c_str(), "D");
+
+ // FIXME: We should print only the value or the constant not the type.
+ std::string prettyData;
+ llvm::raw_string_ostream OSData(prettyData);
+ V10.printData(OSData);
+ EXPECT_STREQ(prettyData.c_str(), "(One) : unsigned int 1");
+
+ std::string prettyPrint;
+ llvm::raw_string_ostream OSPrint(prettyPrint);
+ V10.print(OSPrint);
+ EXPECT_STREQ(prettyPrint.c_str(), "(D) (One) : unsigned int 1\n");
}
TEST_F(InterpreterTest, TranslationUnit_CanonicalDecl) {
diff --git a/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp b/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
index 46dbb4d..ddc8792 100644
--- a/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
+++ b/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
@@ -640,14 +640,14 @@ TEST(MinimizeSourceToDependencyDirectivesTest, AtImport) {
EXPECT_STREQ("@import A;\n", Out.data());
ASSERT_FALSE(minimizeSourceToDependencyDirectives("@import A\n;", Out));
- EXPECT_STREQ("@import A;\n", Out.data());
+ EXPECT_STREQ("@import A\n;\n", Out.data());
ASSERT_FALSE(minimizeSourceToDependencyDirectives("@import A.B;\n", Out));
EXPECT_STREQ("@import A.B;\n", Out.data());
ASSERT_FALSE(minimizeSourceToDependencyDirectives(
- "@import /*x*/ A /*x*/ . /*x*/ B /*x*/ \n /*x*/ ; /*x*/", Out));
- EXPECT_STREQ("@import A.B;\n", Out.data());
+ "@import /*x*/ A /*x*/ . /*x*/ B /*x*/ \\n /*x*/ ; /*x*/", Out));
+ EXPECT_STREQ("@import A.B\\n;\n", Out.data());
}
TEST(MinimizeSourceToDependencyDirectivesTest, EmptyIncludesAndImports) {
@@ -1122,16 +1122,23 @@ ort \
)";
ASSERT_FALSE(
minimizeSourceToDependencyDirectives(Source, Out, Tokens, Directives));
- EXPECT_STREQ("#include \"textual-header.h\"\nexport module m;"
- "exp\\\nort import:l[[rename]];"
- "import<<=3;import a b d e d e f e;"
- "import foo[[no_unique_address]];import foo();"
- "import f(:sefse);import f(->a=3);"
+
+ EXPECT_STREQ("module;\n"
+ "#include \"textual-header.h\"\n"
+ "export module m;\n"
+ "exp\\\nort import:l[[rename]];\n"
+ "import<<=3;\n"
+ "import a b d e d e f e;\n"
+ "import foo[[no_unique_address]];\n"
+ "import foo();\n"
+ "import f(:sefse);\n"
+ "import f(->a=3);\n"
"<TokBeforeEOF>\n",
Out.data());
- ASSERT_EQ(Directives.size(), 11u);
- EXPECT_EQ(Directives[0].Kind, pp_include);
- EXPECT_EQ(Directives[1].Kind, cxx_export_module_decl);
+ ASSERT_EQ(Directives.size(), 12u);
+ EXPECT_EQ(Directives[0].Kind, cxx_module_decl);
+ EXPECT_EQ(Directives[1].Kind, pp_include);
+ EXPECT_EQ(Directives[2].Kind, cxx_export_module_decl);
}
TEST(MinimizeSourceToDependencyDirectivesTest, ObjCMethodArgs) {
diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp
index 9903c12..0213bfe 100644
--- a/clang/unittests/Lex/HeaderSearchTest.cpp
+++ b/clang/unittests/Lex/HeaderSearchTest.cpp
@@ -28,9 +28,9 @@ namespace {
class HeaderSearchTest : public ::testing::Test {
protected:
HeaderSearchTest()
- : VFS(new llvm::vfs::InMemoryFileSystem), FileMgr(FileMgrOpts, VFS),
- DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : VFS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
+ FileMgr(FileMgrOpts, VFS),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions),
Search(HSOpts, SourceMgr, Diags, LangOpts, Target.get()) {
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
@@ -80,7 +80,6 @@ protected:
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS;
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index 86df872..56d73ce 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -41,8 +41,8 @@ using testing::ElementsAre;
class LexerTest : public ::testing::Test {
protected:
LexerTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -102,7 +102,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Lex/ModuleDeclStateTest.cpp b/clang/unittests/Lex/ModuleDeclStateTest.cpp
index 6ecba4d..adc6cf1 100644
--- a/clang/unittests/Lex/ModuleDeclStateTest.cpp
+++ b/clang/unittests/Lex/ModuleDeclStateTest.cpp
@@ -54,8 +54,8 @@ public:
class ModuleDeclStateTest : public ::testing::Test {
protected:
ModuleDeclStateTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
TargetOpts->Triple = "x86_64-unknown-linux-gnu";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -93,7 +93,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp
index af86c18..990689c 100644
--- a/clang/unittests/Lex/PPCallbacksTest.cpp
+++ b/clang/unittests/Lex/PPCallbacksTest.cpp
@@ -133,9 +133,10 @@ public:
class PPCallbacksTest : public ::testing::Test {
protected:
PPCallbacksTest()
- : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
+ : InMemoryFileSystem(
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
FileMgr(FileSystemOptions(), InMemoryFileSystem),
- DiagID(new DiagnosticIDs()),
+ DiagID(DiagnosticIDs::create()),
Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions()) {
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
diff --git a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
index 54c1d02..4a88bd4 100644
--- a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
+++ b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
@@ -29,8 +29,8 @@ namespace {
class PPConditionalDirectiveRecordTest : public ::testing::Test {
protected:
PPConditionalDirectiveRecordTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -38,7 +38,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Lex/PPDependencyDirectivesTest.cpp b/clang/unittests/Lex/PPDependencyDirectivesTest.cpp
index 061cb13..15cc283 100644
--- a/clang/unittests/Lex/PPDependencyDirectivesTest.cpp
+++ b/clang/unittests/Lex/PPDependencyDirectivesTest.cpp
@@ -31,8 +31,8 @@ namespace {
class PPDependencyDirectivesTest : public ::testing::Test {
protected:
PPDependencyDirectivesTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
TargetOpts->Triple = "x86_64-apple-macos12";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -40,7 +40,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
@@ -75,7 +74,7 @@ TEST_F(PPDependencyDirectivesTest, MacroGuard) {
// "head2.h" and "head3.h" have tokens following the macro check, they should
// be included multiple times.
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->addFile(
"head1.h", 0,
llvm::MemoryBuffer::getMemBuffer("#ifndef H1_H\n#define H1_H\n#endif\n"));
diff --git a/clang/unittests/Lex/PPMemoryAllocationsTest.cpp b/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
index 4d83003..f873774 100644
--- a/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
+++ b/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
@@ -27,8 +27,8 @@ namespace {
class PPMemoryAllocationsTest : public ::testing::Test {
protected:
PPMemoryAllocationsTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
+ : FileMgr(FileMgrOpts),
+ Diags(DiagnosticIDs::create(), DiagOpts, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
Target = TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
@@ -36,7 +36,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
DiagnosticsEngine Diags;
SourceManager SourceMgr;
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index 4b24800..44f6b04 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -71,8 +71,8 @@ public:
class ParseHLSLRootSignatureTest : public ::testing::Test {
protected:
ParseHLSLRootSignatureTest()
- : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
- Consumer(new ExpectedDiagConsumer()), Diags(DiagID, DiagOpts, Consumer),
+ : FileMgr(FileMgrOpts), Consumer(new ExpectedDiagConsumer()),
+ Diags(DiagnosticIDs::create(), DiagOpts, Consumer),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) {
// This is an arbitrarily chosen target triple to create the target info.
TargetOpts->Triple = "dxil";
@@ -114,7 +114,6 @@ protected:
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
DiagnosticOptions DiagOpts;
ExpectedDiagConsumer *Consumer;
DiagnosticsEngine Diags;
@@ -136,15 +135,13 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseEmptyTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
- ASSERT_EQ((int)Elements.size(), 0);
+ ASSERT_EQ((int)Parser.getElements().size(), 0);
ASSERT_TRUE(Consumer->isSatisfied());
}
@@ -172,15 +169,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
// First Descriptor Table with 4 elements
RootElement Elem = Elements[0].getElement();
ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
@@ -277,15 +273,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
ASSERT_EQ(Elements.size(), 2u);
// Check default values are as expected
@@ -364,15 +359,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
RootElement Elem = Elements[0].getElement();
ASSERT_TRUE(std::holds_alternative<StaticSampler>(Elem));
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MipLODBias, 0.f);
@@ -441,15 +435,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
RootElement Elem = Elements[0].getElement();
ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::Sampler);
@@ -474,15 +467,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
ASSERT_EQ(Elements.size(), 2u);
RootElement Elem = Elements[0].getElement();
@@ -533,15 +525,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
ASSERT_EQ(Elements.size(), 3u);
RootElement Elem = Elements[0].getElement();
@@ -588,15 +579,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
ASSERT_EQ(Elements.size(), 4u);
RootElement Elem = Elements[0].getElement();
@@ -664,9 +654,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -697,15 +685,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_0, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_0, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
auto DefRootDescriptorFlag = llvm::dxbc::RootDescriptorFlags::DataVolatile;
RootElement Elem = Elements[0].getElement();
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
@@ -770,15 +757,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
ASSERT_FALSE(Parser.parse());
+ auto Elements = Parser.getElements();
RootElement Elem = Elements[0].getElement();
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::CBuffer);
@@ -838,9 +824,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -860,9 +844,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced - invalid token
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -882,9 +864,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced - expected '(' after DescriptorTable
Consumer->setExpected(diag::err_expected_after);
@@ -909,9 +889,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -933,9 +911,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRDParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -957,9 +933,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -983,9 +957,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1007,9 +979,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1033,9 +1003,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1061,9 +1029,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1086,9 +1052,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1110,9 +1074,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseOverflowedNegativeNumberTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1133,9 +1095,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1156,9 +1116,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1179,9 +1137,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1202,9 +1158,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_underflow);
@@ -1228,9 +1182,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_non_zero_flag);
@@ -1253,9 +1205,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRootElementMissingCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -1280,9 +1230,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidDescriptorTableMissingCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -1307,9 +1255,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRootConstantParamsCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -1334,9 +1280,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRootDescriptorParamsCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -1363,9 +1307,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidDescriptorClauseParamsCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -1390,9 +1332,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidStaticSamplerCommaTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_expected_either);
@@ -1414,9 +1354,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRootDescriptorParamTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1441,9 +1379,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidDescriptorTableParamTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1467,9 +1403,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidDescriptorTableClauseParamTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1496,9 +1430,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidStaticSamplerParamTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1523,9 +1455,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidVisibilityValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1549,9 +1479,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRegisterValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1576,9 +1504,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidFilterValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1603,9 +1529,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidTextureAddressModeValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1630,9 +1554,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidComparisonFuncValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1657,9 +1579,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidStaticBorderColorValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1681,9 +1601,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRootFlagsValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1705,9 +1623,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRootDescriptorFlagsValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
@@ -1733,9 +1649,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidDescriptorRangeFlagsValueTest) {
TrivialModuleLoader ModLoader;
auto PP = createPP(Source, ModLoader);
- SmallVector<RootSignatureElement> Elements;
- hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements,
- Signature, *PP);
+ hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Signature, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_invalid_token);
diff --git a/clang/unittests/Sema/SemaNoloadLookupTest.cpp b/clang/unittests/Sema/SemaNoloadLookupTest.cpp
index 5a04f42..e565372 100644
--- a/clang/unittests/Sema/SemaNoloadLookupTest.cpp
+++ b/clang/unittests/Sema/SemaNoloadLookupTest.cpp
@@ -82,7 +82,7 @@ public:
EXPECT_TRUE(Invocation);
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
Instance.getFrontendOpts().OutputFile = CacheBMIPath;
GenerateReducedModuleInterfaceAction Action;
EXPECT_TRUE(Instance.ExecuteAction(Action));
diff --git a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
index 970eeef..92ff76b 100644
--- a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
+++ b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
@@ -87,7 +87,7 @@ export int aa = 43;
Buf->release();
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
Instance.getFrontendOpts().OutputFile = BMIPath;
@@ -122,7 +122,7 @@ export int aa = 43;
CompilerInstance Clang(std::move(Invocation));
- Clang.setDiagnostics(Diags.get());
+ Clang.setDiagnostics(Diags);
FileManager *FM = Clang.createFileManager(CIOpts.VFS);
Clang.createSourceManager(*FM);
diff --git a/clang/unittests/Serialization/LoadSpecLazilyTest.cpp b/clang/unittests/Serialization/LoadSpecLazilyTest.cpp
index 6315474..d7b5549 100644
--- a/clang/unittests/Serialization/LoadSpecLazilyTest.cpp
+++ b/clang/unittests/Serialization/LoadSpecLazilyTest.cpp
@@ -80,7 +80,7 @@ public:
EXPECT_TRUE(Invocation);
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
Instance.getFrontendOpts().OutputFile = CacheBMIPath;
// Avoid memory leaks.
Instance.getFrontendOpts().DisableFree = false;
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp b/clang/unittests/Serialization/ModuleCacheTest.cpp
index de6e13a..1f64401 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -121,7 +121,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
createInvocationAndEnableFree(Args, CIOpts);
ASSERT_TRUE(Invocation);
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
SyntaxOnlyAction Action;
ASSERT_TRUE(Instance.ExecuteAction(Action));
ASSERT_FALSE(Diags->hasErrorOccurred());
@@ -145,7 +145,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
CompilerInstance Instance2(std::move(Invocation2),
Instance.getPCHContainerOperations(),
&Instance.getModuleCache());
- Instance2.setDiagnostics(Diags.get());
+ Instance2.setDiagnostics(Diags);
SyntaxOnlyAction Action2;
ASSERT_FALSE(Instance2.ExecuteAction(Action2));
ASSERT_TRUE(Diags->hasErrorOccurred());
@@ -171,7 +171,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
createInvocationAndEnableFree(Args, CIOpts);
ASSERT_TRUE(Invocation);
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
SyntaxOnlyAction Action;
ASSERT_TRUE(Instance.ExecuteAction(Action));
ASSERT_FALSE(Diags->hasErrorOccurred());
@@ -189,7 +189,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
CompilerInstance Instance2(std::move(Invocation2),
Instance.getPCHContainerOperations(),
&Instance.getModuleCache());
- Instance2.setDiagnostics(Diags.get());
+ Instance2.setDiagnostics(Diags);
SyntaxOnlyAction Action2;
ASSERT_FALSE(Instance2.ExecuteAction(Action2));
ASSERT_TRUE(Diags->hasErrorOccurred());
diff --git a/clang/unittests/Serialization/NoCommentsTest.cpp b/clang/unittests/Serialization/NoCommentsTest.cpp
index 05efeef..ed96c7c 100644
--- a/clang/unittests/Serialization/NoCommentsTest.cpp
+++ b/clang/unittests/Serialization/NoCommentsTest.cpp
@@ -99,7 +99,7 @@ void foo() {}
ASSERT_TRUE(Invocation);
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
Instance.getFrontendOpts().OutputFile = CacheBMIPath;
GenerateReducedModuleInterfaceAction Action;
ASSERT_TRUE(Instance.ExecuteAction(Action));
diff --git a/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp b/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp
index c43520f..f9d7736 100644
--- a/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp
+++ b/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp
@@ -101,7 +101,7 @@ export using ::E;
PreambleCallbacks Callbacks;
llvm::ErrorOr<PrecompiledPreamble> BuiltPreamble = PrecompiledPreamble::Build(
- *Invocation, Buffer.get(), Bounds, *Diags, VFS,
+ *Invocation, Buffer.get(), Bounds, Diags, VFS,
std::make_shared<PCHContainerOperations>(),
/*StoreInMemory=*/false, /*StoragePath=*/TestDir, Callbacks);
@@ -112,7 +112,7 @@ export using ::E;
BuiltPreamble->OverridePreamble(*Invocation, VFS, Buffer.get());
auto Clang = std::make_unique<CompilerInstance>(std::move(Invocation));
- Clang->setDiagnostics(Diags.get());
+ Clang->setDiagnostics(Diags);
if (auto VFSWithRemapping = createVFSFromCompilerInvocation(
Clang->getInvocation(), Clang->getDiagnostics(), VFS))
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 5b2988e..743f851 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -106,7 +106,7 @@ export namespace Fibonacci
Invocation->getFrontendOpts().DisableFree = false;
CompilerInstance Instance(std::move(Invocation));
- Instance.setDiagnostics(Diags.get());
+ Instance.setDiagnostics(Diags);
std::string CacheBMIPath = llvm::Twine(TestDir + "/Cached.pcm").str();
Instance.getFrontendOpts().OutputFile = CacheBMIPath;
diff --git a/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp b/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
index 0f05c39..d15bec0 100644
--- a/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
+++ b/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
@@ -91,8 +91,7 @@ void addBlockEntranceTester(AnalysisASTConsumer &AnalysisConsumer,
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker(&registerChecker<BlockEntranceCallbackTester>,
&shouldAlwaysRegister, "test.BlockEntranceTester",
- "EmptyDescription", "EmptyDocsUri",
- /*IsHidden=*/false);
+ "EmptyDescription");
});
}
@@ -102,8 +101,7 @@ void addBranchConditionTester(AnalysisASTConsumer &AnalysisConsumer,
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker(&registerChecker<BranchConditionCallbackTester>,
&shouldAlwaysRegister, "test.BranchConditionTester",
- "EmptyDescription", "EmptyDocsUri",
- /*IsHidden=*/false);
+ "EmptyDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
index 0ef63b0..fc50f00 100644
--- a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
+++ b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
@@ -120,7 +120,7 @@ public:
std::move(ExpectedDiags), Compiler.getSourceManager()));
AnalysisConsumer->AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<InterestingnessTestChecker>("test.Interestingness",
- "Description", "");
+ "MockDescription");
});
Compiler.getAnalyzerOpts().CheckersAndPackages = {
{"test.Interestingness", true}};
diff --git a/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp b/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
index 4cb6bd3..e2007a9 100644
--- a/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
+++ b/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
@@ -616,8 +616,8 @@ void addCallDescChecker(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
AnOpts.CheckersAndPackages = {{"test.CallDescChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<CallDescChecker>("test.CallDescChecker", "Description",
- "");
+ Registry.addChecker<CallDescChecker>("test.CallDescChecker",
+ "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/CallEventTest.cpp b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
index 2843572e..8b5289e 100644
--- a/clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -56,7 +56,7 @@ void addCXXDeallocatorChecker(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"test.CXXDeallocator", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<CXXDeallocatorChecker>("test.CXXDeallocator",
- "Description", "");
+ "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp b/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
index e410cca..cffdbf1 100644
--- a/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
@@ -33,10 +33,8 @@ void addEvalFooCheckers(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"test.EvalFoo1", true},
{"test.EvalFoo2", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<EvalCallFoo1>("test.EvalFoo1", "EmptyDescription",
- "EmptyDocsUri");
- Registry.addChecker<EvalCallFoo2>("test.EvalFoo2", "EmptyDescription",
- "EmptyDocsUri");
+ Registry.addChecker<EvalCallFoo1>("test.EvalFoo1", "MockDescription");
+ Registry.addChecker<EvalCallFoo2>("test.EvalFoo2", "MockDescription");
});
}
} // namespace
diff --git a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
index b6eeb9c..12be228 100644
--- a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
@@ -78,7 +78,7 @@ void addExprEngineVisitPreChecker(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"ExprEngineVisitPreChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<ExprEngineVisitPreChecker>("ExprEngineVisitPreChecker",
- "Desc", "DocsURI");
+ "MockDescription");
});
}
@@ -87,7 +87,7 @@ void addExprEngineVisitPostChecker(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"ExprEngineVisitPostChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<ExprEngineVisitPostChecker>(
- "ExprEngineVisitPostChecker", "Desc", "DocsURI");
+ "ExprEngineVisitPostChecker", "MockDescription");
});
}
@@ -95,8 +95,8 @@ void addMemAccessChecker(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
AnOpts.CheckersAndPackages = {{"MemAccessChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<MemAccessChecker>("MemAccessChecker", "Desc",
- "DocsURI");
+ Registry.addChecker<MemAccessChecker>("MemAccessChecker",
+ "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
index 8f0a96d..146797f 100644
--- a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -92,8 +92,8 @@ void addFalsePositiveGenerator(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"test.FalsePositiveGenerator", true},
{"debug.ViewExplodedGraph", false}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<FalsePositiveGenerator>(
- "test.FalsePositiveGenerator", "EmptyDescription", "EmptyDocsUri");
+ Registry.addChecker<FalsePositiveGenerator>("test.FalsePositiveGenerator",
+ "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp b/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp
index 0f6e49b..7b837f3 100644
--- a/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp
+++ b/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp
@@ -46,7 +46,7 @@ void addDescriptiveNameChecker(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"DescriptiveNameChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<DescriptiveNameChecker>("DescriptiveNameChecker",
- "Desc", "DocsURI");
+ "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp b/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp
index a903342..68d2678 100644
--- a/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp
+++ b/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp
@@ -140,7 +140,7 @@ void addNonThoroughStatefulChecker(AnalysisASTConsumer &AnalysisConsumer,
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry
.addChecker<StatefulChecker<NonThoroughErrorNotPreventedFuncVisitor>>(
- "test.StatefulChecker", "Description", "");
+ "test.StatefulChecker", "MockDescription");
});
}
@@ -233,7 +233,7 @@ void addThoroughStatefulChecker(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"test.StatefulChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<StatefulChecker<ThoroughErrorNotPreventedFuncVisitor>>(
- "test.StatefulChecker", "Description", "");
+ "test.StatefulChecker", "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp b/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp
index 51bd332..ab78090 100644
--- a/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp
+++ b/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp
@@ -37,7 +37,7 @@ void addFlagFlipperChecker(AnalysisASTConsumer &AnalysisConsumer,
AnOpts.CheckersAndPackages = {{"test.FlipFlagOnCheckLocation", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker<FlipFlagOnCheckLocation>("test.FlipFlagOnCheckLocation",
- "Description", "");
+ "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
index 454eee9..e17d107 100644
--- a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -44,7 +44,7 @@ void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
AnOpts.CheckersAndPackages = {{"test.CustomChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<CustomChecker>("test.CustomChecker", "Description", "");
+ Registry.addChecker<CustomChecker>("test.CustomChecker", "MockDescription");
});
}
@@ -73,8 +73,8 @@ void addLocIncDecChecker(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
AnOpts.CheckersAndPackages = {{"test.LocIncDecChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<CustomChecker>("test.LocIncDecChecker", "Description",
- "");
+ Registry.addChecker<CustomChecker>("test.LocIncDecChecker",
+ "MockDescription");
});
}
@@ -119,10 +119,10 @@ bool shouldRegisterCheckerRegistrationOrderPrinter(const CheckerManager &mgr) {
void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) {
Registry.addChecker(registerCheckerRegistrationOrderPrinter,
shouldRegisterCheckerRegistrationOrderPrinter,
- "test.RegistrationOrder", "Description", "", false);
+ "test.RegistrationOrder", "Description");
}
-#define UNITTEST_CHECKER(CHECKER_NAME, DIAG_MSG) \
+#define UNITTEST_CHECKER(CHECKER_NAME) \
class CHECKER_NAME : public Checker<check::PreStmt<DeclStmt>> { \
public: \
void checkPreStmt(const DeclStmt *DS, CheckerContext &C) const {} \
@@ -137,11 +137,11 @@ void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) {
} \
void add##CHECKER_NAME(CheckerRegistry &Registry) { \
Registry.addChecker(register##CHECKER_NAME, shouldRegister##CHECKER_NAME, \
- "test." #CHECKER_NAME, "Description", "", false); \
+ "test." #CHECKER_NAME, "Description"); \
}
-UNITTEST_CHECKER(StrongDep, "Strong")
-UNITTEST_CHECKER(Dep, "Dep")
+UNITTEST_CHECKER(StrongDep)
+UNITTEST_CHECKER(Dep)
bool shouldRegisterStrongFALSE(const CheckerManager &mgr) {
return false;
@@ -154,7 +154,7 @@ void addDep(AnalysisASTConsumer &AnalysisConsumer,
{"test.RegistrationOrder", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
Registry.addChecker(registerStrongDep, shouldRegisterStrongFALSE,
- "test.Strong", "Description", "", false);
+ "test.Strong", "Description");
addStrongDep(Registry);
addDep(Registry);
addCheckerRegistrationOrderPrinter(Registry);
@@ -172,7 +172,7 @@ TEST(RegisterDeps, UnsatisfiedDependency) {
// Weak checker dependencies.
//===----------------------------------------------------------------------===//
-UNITTEST_CHECKER(WeakDep, "Weak")
+UNITTEST_CHECKER(WeakDep)
void addWeakDepCheckerBothEnabled(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
@@ -225,8 +225,8 @@ void addWeakDepCheckerDepUnspecified(AnalysisASTConsumer &AnalysisConsumer,
});
}
-UNITTEST_CHECKER(WeakDep2, "Weak2")
-UNITTEST_CHECKER(Dep2, "Dep2")
+UNITTEST_CHECKER(WeakDep2)
+UNITTEST_CHECKER(Dep2)
void addWeakDepHasWeakDep(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
diff --git a/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp b/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp
index 85cfe2c..4331ffc 100644
--- a/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp
+++ b/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp
@@ -68,8 +68,7 @@ static void addSimplifyChecker(AnalysisASTConsumer &AnalysisConsumer,
AnalyzerOptions &AnOpts) {
AnOpts.CheckersAndPackages = {{"SimplifyChecker", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<SimplifyChecker>("SimplifyChecker", "EmptyDescription",
- "EmptyDocsUri");
+ Registry.addChecker<SimplifyChecker>("SimplifyChecker", "MockDescription");
});
}
diff --git a/clang/unittests/StaticAnalyzer/SValTest.cpp b/clang/unittests/StaticAnalyzer/SValTest.cpp
index d8897b0..58e9a8d 100644
--- a/clang/unittests/StaticAnalyzer/SValTest.cpp
+++ b/clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -139,10 +139,10 @@ class SValTest : public testing::TestWithParam<TestClangConfig> {};
\
void add##NAME##SValCollector(AnalysisASTConsumer &AnalysisConsumer, \
AnalyzerOptions &AnOpts) { \
- AnOpts.CheckersAndPackages = {{"test.##NAME##SValCollector", true}}; \
+ AnOpts.CheckersAndPackages = {{"test." #NAME "SValColl", true}}; \
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { \
- Registry.addChecker<NAME##SValCollector>("test.##NAME##SValCollector", \
- "Description", ""); \
+ Registry.addChecker<NAME##SValCollector>("test." #NAME "SValColl", \
+ "MockDescription"); \
}); \
} \
\
diff --git a/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp b/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
index 5fc084a..0cb3c59 100644
--- a/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
+++ b/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
@@ -49,9 +49,9 @@ void addTestReturnValueUnderConstructionChecker(
AnOpts.CheckersAndPackages =
{{"test.TestReturnValueUnderConstruction", true}};
AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
- Registry.addChecker<TestReturnValueUnderConstructionChecker>(
- "test.TestReturnValueUnderConstruction", "", "");
- });
+ Registry.addChecker<TestReturnValueUnderConstructionChecker>(
+ "test.TestReturnValueUnderConstruction", "MockDescription");
+ });
}
TEST(TestReturnValueUnderConstructionChecker,
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp b/clang/unittests/Support/TimeProfilerTest.cpp
index 85d36b5..f70149d 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -46,8 +46,7 @@ std::string teardownProfiler() {
bool compileFromString(StringRef Code, StringRef Standard, StringRef File,
llvm::StringMap<std::string> Headers = {}) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
- new llvm::vfs::InMemoryFileSystem());
+ auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FS->addFile(File, 0, MemoryBuffer::getMemBuffer(Code));
for (const auto &Header : Headers) {
FS->addFile(Header.getKey(), 0,
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index c1febaf..2d68e09 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -971,7 +971,8 @@ TEST_F(TargetAndModeTest, TargetAndMode) {
class ExpandResponseFilesTest : public MemDBTest {
public:
- ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
+ ExpandResponseFilesTest()
+ : FS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()) {}
protected:
void addFile(StringRef File, StringRef Content) {
diff --git a/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp b/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp
index 1cdb539..b16dd8e 100644
--- a/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp
+++ b/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp
@@ -85,7 +85,7 @@ TEST(DependencyScanner, ScanDepsReuseFilemanager) {
StringRef CWD = "/root";
FixedCompilationDatabase CDB(CWD, Compilation);
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
std::string HeaderPath =
@@ -134,7 +134,7 @@ TEST(DependencyScanner, ScanDepsReuseFilemanagerSkippedFile) {
StringRef CWD = "/root";
FixedCompilationDatabase CDB(CWD, Compilation);
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
std::string HeaderPath =
@@ -176,7 +176,7 @@ TEST(DependencyScanner, ScanDepsReuseFilemanagerHasInclude) {
StringRef CWD = "/root";
FixedCompilationDatabase CDB(CWD, Compilation);
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
std::string HeaderPath =
@@ -218,7 +218,7 @@ TEST(DependencyScanner, ScanDepsWithFS) {
"test.cpp.o"};
StringRef CWD = "/root";
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
std::string HeaderPath =
@@ -256,7 +256,7 @@ TEST(DependencyScanner, ScanDepsWithModuleLookup) {
};
StringRef CWD = "/root";
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
std::string OtherPath =
@@ -306,7 +306,7 @@ TEST(DependencyScanner, ScanDepsWithModuleLookup) {
TEST(DependencyScanner, ScanDepsWithDiagConsumer) {
StringRef CWD = "/root";
- auto VFS = new llvm::vfs::InMemoryFileSystem();
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
std::string HeaderPath =
diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp
index 35d1143..aff7523e 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -1035,8 +1035,7 @@ static constexpr bool usesWindowsPaths() {
TEST(DeduplicateByFileTest, PathsWithDots) {
std::map<std::string, Replacements> FileToReplaces;
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
- new llvm::vfs::InMemoryFileSystem());
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FileManager FileMgr(FileSystemOptions(), VFS);
StringRef Path1 = usesWindowsPaths() ? "a\\b\\..\\.\\c.h" : "a/b/.././c.h";
StringRef Path2 = usesWindowsPaths() ? "a\\c.h" : "a/c.h";
@@ -1051,8 +1050,7 @@ TEST(DeduplicateByFileTest, PathsWithDots) {
TEST(DeduplicateByFileTest, PathWithDotSlash) {
std::map<std::string, Replacements> FileToReplaces;
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
- new llvm::vfs::InMemoryFileSystem());
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FileManager FileMgr(FileSystemOptions(), VFS);
StringRef Path1 = usesWindowsPaths() ? ".\\a\\b\\c.h" : "./a/b/c.h";
StringRef Path2 = usesWindowsPaths() ? "a\\b\\c.h" : "a/b/c.h";
@@ -1067,8 +1065,7 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) {
TEST(DeduplicateByFileTest, NonExistingFilePath) {
std::map<std::string, Replacements> FileToReplaces;
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
- new llvm::vfs::InMemoryFileSystem());
+ auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FileManager FileMgr(FileSystemOptions(), VFS);
StringRef Path1 = usesWindowsPaths() ? ".\\a\\b\\c.h" : "./a/b/c.h";
StringRef Path2 = usesWindowsPaths() ? "a\\b\\c.h" : "a/b/c.h";
diff --git a/clang/unittests/Tooling/RewriterTestContext.h b/clang/unittests/Tooling/RewriterTestContext.h
index 2d697e2..020ef60 100644
--- a/clang/unittests/Tooling/RewriterTestContext.h
+++ b/clang/unittests/Tooling/RewriterTestContext.h
@@ -49,11 +49,12 @@ struct RewriterDiagnosticConsumer : public DiagnosticConsumer {
class RewriterTestContext {
public:
RewriterTestContext()
- : Diagnostics(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
- DiagOpts),
- InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
+ : Diagnostics(DiagnosticIDs::create(), DiagOpts),
+ InMemoryFileSystem(
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())),
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem())),
Files(FileSystemOptions(), OverlayFileSystem),
Sources(Diagnostics, Files), Rewrite(Sources, Options) {
Diagnostics.setClient(&DiagnosticPrinter, false);
diff --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index b5f4445..e86793f 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -133,7 +133,7 @@ public:
CI->getPreprocessorOpts().addRemappedFile(
FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
CompilerInstance Compiler(std::move(CI));
- Compiler.setDiagnostics(Diags.get());
+ Compiler.setDiagnostics(Diags);
Compiler.setFileManager(FileMgr.get());
Compiler.setSourceManager(SourceMgr.get());
@@ -250,9 +250,10 @@ public:
// Data fields.
DiagnosticOptions DiagOpts;
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
- new DiagnosticsEngine(new DiagnosticIDs, DiagOpts);
+ llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagnosticIDs::create(),
+ DiagOpts);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
- new llvm::vfs::InMemoryFileSystem;
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
llvm::IntrusiveRefCntPtr<FileManager> FileMgr =
new FileManager(FileSystemOptions(), FS);
llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr =
diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
index 9f22b1d..4a25863 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -152,7 +152,7 @@ SyntaxTreeTest::buildTree(StringRef Code, const TestClangConfig &ClangConfig) {
Invocation->getPreprocessorOpts().addRemappedFile(
FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
CompilerInstance Compiler(Invocation);
- Compiler.setDiagnostics(Diags.get());
+ Compiler.setDiagnostics(Diags);
Compiler.setFileManager(FileMgr.get());
Compiler.setSourceManager(SourceMgr.get());
diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.h b/clang/unittests/Tooling/Syntax/TreeTestBase.h
index 6110cff..fce89e2 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -42,9 +42,10 @@ protected:
// Data fields.
DiagnosticOptions DiagOpts;
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
- new DiagnosticsEngine(new DiagnosticIDs, DiagOpts);
+ llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagnosticIDs::create(),
+ DiagOpts);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
- new llvm::vfs::InMemoryFileSystem;
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
IntrusiveRefCntPtr<FileManager> FileMgr =
new FileManager(FileSystemOptions(), FS);
IntrusiveRefCntPtr<SourceManager> SourceMgr =
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp
index 32af4b6..c72676f 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -153,8 +153,8 @@ TEST(buildASTFromCode, ReportsErrors) {
}
TEST(buildASTFromCode, FileSystem) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
InMemoryFileSystem->addFile("included_file.h", 0,
llvm::MemoryBuffer::getMemBufferCopy("class X;"));
std::unique_ptr<ASTUnit> AST = buildASTFromCodeWithArgs(
@@ -188,10 +188,11 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {
}
TEST(ToolInvocation, TestMapVirtualFile) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -214,10 +215,11 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) {
// mapped module.modulemap is found on the include path. In the future, expand
// this test to run a full modules enabled compilation, so we make sure we can
// rerun modules compilations with a virtual file system.
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -240,10 +242,11 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) {
}
TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -269,10 +272,11 @@ TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
}
TEST(ToolInvocation, CustomDiagnosticOptionsOverwriteParsedOnes) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -315,10 +319,11 @@ struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
};
TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -341,10 +346,11 @@ TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
}
TEST(ToolInvocation, CC1Args) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -361,10 +367,11 @@ TEST(ToolInvocation, CC1Args) {
}
TEST(ToolInvocation, CC1ArgsInvalid) {
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
@@ -398,7 +405,7 @@ struct CommandLineExtractorTest : public ::testing::Test {
public:
CommandLineExtractorTest()
- : InMemoryFS(new llvm::vfs::InMemoryFileSystem),
+ : InMemoryFS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
Diags(CompilerInstance::createDiagnostics(*InMemoryFS, DiagOpts)),
Driver("clang", llvm::sys::getDefaultTargetTriple(), *Diags,
"clang LLVM compiler", overlayRealFS(InMemoryFS)) {}
@@ -755,10 +762,11 @@ TEST(ClangToolTest, NoOutputCommands) {
TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
FixedCompilationDatabase Compilations("/", std::vector<std::string>());
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
InMemoryFileSystem->addFile(