[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
//===- clang-apply-replacements/ApplyReplacementsTest.cpp
|
|
|
|
//----------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
|
2018-04-11 22:39:17 +08:00
|
|
|
#include "clang/Format/Format.h"
|
[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
using namespace clang::replace;
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tooling {
|
|
|
|
|
|
|
|
static TUDiagnostics
|
|
|
|
makeTUDiagnostics(const std::string &MainSourceFile, StringRef DiagnosticName,
|
|
|
|
const DiagnosticMessage &Message,
|
|
|
|
const StringMap<Replacements> &Replacements,
|
|
|
|
StringRef BuildDirectory) {
|
|
|
|
TUDiagnostics TUs;
|
2021-03-16 00:06:03 +08:00
|
|
|
TUs.push_back(
|
|
|
|
{MainSourceFile,
|
|
|
|
{{DiagnosticName, Message, {}, Diagnostic::Warning, BuildDirectory}}});
|
[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
return TUs;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test to ensure diagnostics with no fixes, will be merged correctly
|
|
|
|
// before applying.
|
|
|
|
TEST(ApplyReplacementsTest, mergeDiagnosticsWithNoFixes) {
|
|
|
|
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions());
|
|
|
|
DiagnosticsEngine Diagnostics(
|
|
|
|
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts.get());
|
|
|
|
FileManager Files((FileSystemOptions()));
|
|
|
|
SourceManager SM(Diagnostics, Files);
|
2018-04-11 22:39:17 +08:00
|
|
|
TUReplacements TURs;
|
[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
TUDiagnostics TUs =
|
|
|
|
makeTUDiagnostics("path/to/source.cpp", "diagnostic", {}, {}, "path/to");
|
2018-04-11 22:39:17 +08:00
|
|
|
FileToChangesMap ReplacementsMap;
|
[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
|
2018-04-11 22:39:17 +08:00
|
|
|
EXPECT_TRUE(mergeAndDeduplicate(TURs, TUs, ReplacementsMap, SM));
|
[Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
2017-07-14 18:37:46 +08:00
|
|
|
EXPECT_TRUE(ReplacementsMap.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace tooling
|
|
|
|
} // end namespace clang
|