1 //===- clang-apply-replacements/ApplyReplacementsTest.cpp
2 //----------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #include "clang-apply-replacements/Tooling/ApplyReplacements.h"
11 #include "clang/Format/Format.h"
12 #include "gtest/gtest.h"
14 using namespace clang::replace
;
21 makeTUDiagnostics(const std::string
&MainSourceFile
, StringRef DiagnosticName
,
22 const DiagnosticMessage
&Message
,
23 const StringMap
<Replacements
> &Replacements
,
24 StringRef BuildDirectory
) {
28 {{DiagnosticName
, Message
, {}, Diagnostic::Warning
, BuildDirectory
}}});
32 // Test to ensure diagnostics with no fixes, will be merged correctly
34 TEST(ApplyReplacementsTest
, mergeDiagnosticsWithNoFixes
) {
35 IntrusiveRefCntPtr
<DiagnosticOptions
> DiagOpts(new DiagnosticOptions());
36 DiagnosticsEngine
Diagnostics(
37 IntrusiveRefCntPtr
<DiagnosticIDs
>(new DiagnosticIDs()), DiagOpts
.get());
38 FileManager
Files((FileSystemOptions()));
39 SourceManager
SM(Diagnostics
, Files
);
42 makeTUDiagnostics("path/to/source.cpp", "diagnostic", {}, {}, "path/to");
43 FileToChangesMap ReplacementsMap
;
45 EXPECT_TRUE(mergeAndDeduplicate(TURs
, TUs
, ReplacementsMap
, SM
));
46 EXPECT_TRUE(ReplacementsMap
.empty());
49 } // end namespace tooling
50 } // end namespace clang