[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
|
|
|
|
//----------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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;
|
|
|
|
TUs.push_back({MainSourceFile,
|
|
|
|
{{DiagnosticName,
|
|
|
|
Message,
|
|
|
|
Replacements,
|
|
|
|
{},
|
|
|
|
Diagnostic::Warning,
|
|
|
|
BuildDirectory}}});
|
|
|
|
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
|