[clang-tools-extra] r198875 - Re-applied r198807, r198808 with an additional change to fix linking in configure Release+Asserts build.
Alexander Kornienko
alexfh at google.com
Thu Jan 9 08:31:25 PST 2014
Author: alexfh
Date: Thu Jan 9 10:31:25 2014
New Revision: 198875
URL: http://llvm.org/viewvc/llvm-project?rev=198875&view=rev
Log:
Re-applied r198807, r198808 with an additional change to fix linking in configure Release+Asserts build.
Added:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
- copied unchanged from r198831, clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/unittests/clang-tidy/Makefile
Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=198875&r1=198874&r2=198875&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Thu Jan 9 10:31:25 2014
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
add_clang_library(clangTidy
ClangTidy.cpp
ClangTidyModule.cpp
+ ClangTidyDiagnosticConsumer.cpp
)
target_link_libraries(clangTidy
clangAST
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=198875&r1=198874&r2=198875&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Jan 9 10:31:25 2014
@@ -174,38 +174,6 @@ bool ChecksFilter::IsCheckEnabled(String
return EnableChecks.match(Name) && !DisableChecks.match(Name);
}
-ClangTidyMessage::ClangTidyMessage(StringRef Message) : Message(Message) {}
-
-ClangTidyMessage::ClangTidyMessage(StringRef Message,
- const SourceManager &Sources,
- SourceLocation Loc)
- : Message(Message) {
- FilePath = Sources.getFilename(Loc);
- FileOffset = Sources.getFileOffset(Loc);
-}
-
-ClangTidyError::ClangTidyError(const ClangTidyMessage &Message)
- : Message(Message) {}
-
-DiagnosticBuilder ClangTidyContext::Diag(SourceLocation Loc,
- StringRef Message) {
- return DiagEngine->Report(
- Loc, DiagEngine->getCustomDiagID(DiagnosticsEngine::Warning, Message));
-}
-
-void ClangTidyContext::setDiagnosticsEngine(DiagnosticsEngine *Engine) {
- DiagEngine = Engine;
-}
-
-void ClangTidyContext::setSourceManager(SourceManager *SourceMgr) {
- DiagEngine->setSourceManager(SourceMgr);
-}
-
-/// \brief Store a \c ClangTidyError.
-void ClangTidyContext::storeError(const ClangTidyError &Error) {
- Errors->push_back(Error);
-}
-
void ClangTidyCheck::run(const ast_matchers::MatchFinder::MatchResult &Result) {
Context->setSourceManager(Result.SourceManager);
check(Result);
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=198875&r1=198874&r2=198875&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Thu Jan 9 10:31:25 2014
@@ -13,7 +13,6 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Tooling/Refactoring.h"
-#include "llvm/ADT/SmallString.h"
namespace clang {
@@ -103,63 +102,20 @@ private:
// implementation file.
class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
public:
- ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx) : Context(Ctx) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
- Diags.reset(new DiagnosticsEngine(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, this,
- /*ShouldOwnClient=*/false));
- Context.setDiagnosticsEngine(Diags.get());
- }
+ ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx);
// FIXME: The concept of converting between FixItHints and Replacements is
// more generic and should be pulled out into a more useful Diagnostics
// library.
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) LLVM_OVERRIDE {
- // FIXME: Ensure that we don't get notes from user code related to errors
- // from non-user code.
- if (Diags->getSourceManager().isInSystemHeader(Info.getLocation()))
- return;
- if (DiagLevel != DiagnosticsEngine::Note) {
- Errors.push_back(ClangTidyError(getMessage(Info)));
- } else {
- assert(!Errors.empty() &&
- "A diagnostic note can only be appended to a message.");
- Errors.back().Notes.push_back(getMessage(Info));
- }
- addFixes(Info, Errors.back());
- }
+ const Diagnostic &Info) LLVM_OVERRIDE;
// Flushes the internal diagnostics buffer to the ClangTidyContext.
- virtual void finish() LLVM_OVERRIDE {
- for (unsigned i = 0, e = Errors.size(); i != e; ++i) {
- Context.storeError(Errors[i]);
- }
- Errors.clear();
- }
+ virtual void finish() LLVM_OVERRIDE;
private:
- void addFixes(const Diagnostic &Info, ClangTidyError &Error) {
- if (!Info.hasSourceManager())
- return;
- SourceManager &SourceMgr = Info.getSourceManager();
- tooling::Replacements Replacements;
- for (unsigned i = 0, e = Info.getNumFixItHints(); i != e; ++i) {
- Error.Fix.insert(tooling::Replacement(
- SourceMgr, Info.getFixItHint(i).RemoveRange.getBegin(), 0,
- Info.getFixItHint(i).CodeToInsert));
- }
- }
-
- ClangTidyMessage getMessage(const Diagnostic &Info) const {
- SmallString<100> Buf;
- Info.FormatDiagnostic(Buf);
- if (!Info.hasSourceManager()) {
- return ClangTidyMessage(Buf.str());
- }
- return ClangTidyMessage(Buf.str(), Info.getSourceManager(),
- Info.getLocation());
- }
+ void addFixes(const Diagnostic &Info, ClangTidyError &Error);
+ ClangTidyMessage getMessage(const Diagnostic &Info) const;
ClangTidyContext &Context;
OwningPtr<DiagnosticsEngine> Diags;
Modified: clang-tools-extra/trunk/unittests/clang-tidy/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/Makefile?rev=198875&r1=198874&r2=198875&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/Makefile (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/Makefile Thu Jan 9 10:31:25 2014
@@ -14,6 +14,7 @@ TESTNAME = ClangTidy
LINK_COMPONENTS := asmparser bitreader support MC MCParser option \
TransformUtils
USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \
+ clangTidy.a \
clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \
clangStaticAnalyzerCore.a \
clangFormat.a clangTooling.a clangFrontend.a clangSerialization.a \
More information about the cfe-commits
mailing list