[PATCH] Expose ClangTidyFrontendActionFactory as a part of the public interface.
Alexander Kornienko
alexfh at google.com
Thu Feb 6 07:13:15 PST 2014
Hi klimek,
http://llvm-reviews.chandlerc.com/D2716
Files:
clang-tidy/ClangTidy.cpp
clang-tidy/ClangTidy.h
Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -260,31 +260,7 @@
Tool.setDiagnosticConsumer(&DiagConsumer);
- class ActionFactory : public FrontendActionFactory {
- public:
- ActionFactory(ClangTidyASTConsumerFactory *ConsumerFactory)
- : ConsumerFactory(ConsumerFactory) {}
- FrontendAction *create() LLVM_OVERRIDE {
- return new Action(ConsumerFactory);
- }
-
- private:
- class Action : public ASTFrontendAction {
- public:
- Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {}
- ASTConsumer *CreateASTConsumer(CompilerInstance &Compiler,
- StringRef File) LLVM_OVERRIDE {
- return Factory->CreateASTConsumer(Compiler, File);
- }
-
- private:
- ClangTidyASTConsumerFactory *Factory;
- };
-
- ClangTidyASTConsumerFactory *ConsumerFactory;
- };
-
- Tool.run(new ActionFactory(new ClangTidyASTConsumerFactory(
+ Tool.run(new ClangTidyFrontendActionFactory(new ClangTidyASTConsumerFactory(
EnableChecksRegex, DisableChecksRegex, Context)));
}
@@ -294,6 +270,7 @@
return SourceLocation();
const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
+ assert(File != NULL && "Invalid file name.");
FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
}
Index: clang-tidy/ClangTidy.h
===================================================================
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -126,6 +126,28 @@
OwningPtr<ClangTidyCheckFactories> CheckFactories;
};
+class ClangTidyFrontendActionFactory : public tooling::FrontendActionFactory {
+public:
+ ClangTidyFrontendActionFactory(ClangTidyASTConsumerFactory *ConsumerFactory)
+ : ConsumerFactory(ConsumerFactory) {}
+ FrontendAction *create() LLVM_OVERRIDE { return new Action(ConsumerFactory); }
+
+private:
+ class Action : public ASTFrontendAction {
+ public:
+ Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {}
+ ASTConsumer *CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File) LLVM_OVERRIDE {
+ return Factory->CreateASTConsumer(Compiler, File);
+ }
+
+ private:
+ ClangTidyASTConsumerFactory *Factory;
+ };
+
+ ClangTidyASTConsumerFactory *ConsumerFactory;
+};
+
/// \brief Fills the list of check names that are enabled when the provided
/// filters are applied.
std::vector<std::string> getCheckNames(StringRef EnableChecksRegex,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2716.1.patch
Type: text/x-patch
Size: 2678 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140206/5cd0f3f3/attachment.bin>
More information about the cfe-commits
mailing list