Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: tools/clang/plugins/FindBadConstructsAction.cpp

Issue 1665363002: Clang plugin to check that unstable types are not used in IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Blacklist types instead Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "FindBadConstructsAction.h" 5 #include "FindBadConstructsAction.h"
6 6
7 #include "clang/AST/ASTConsumer.h" 7 #include "clang/AST/ASTConsumer.h"
8 #include "clang/Frontend/FrontendPluginRegistry.h" 8 #include "clang/Frontend/FrontendPluginRegistry.h"
9 9
10 #include "FindBadConstructsConsumer.h" 10 #include "FindBadConstructsConsumer.h"
11 11
12 using namespace clang; 12 using namespace clang;
13 13
14 namespace chrome_checker { 14 namespace chrome_checker {
15 15
16 namespace { 16 namespace {
17 17
18 class PluginConsumer : public ASTConsumer { 18 class PluginConsumer : public ASTConsumer {
19 public: 19 public:
20 PluginConsumer(CompilerInstance* instance, const Options& options) 20 PluginConsumer(CompilerInstance* instance, const Options& options)
21 : visitor_(*instance, options) {} 21 : visitor_(*instance, options) {}
22 22
23 void HandleTranslationUnit(clang::ASTContext& context) override { 23 void HandleTranslationUnit(clang::ASTContext& context) override {
24 visitor_.TraverseDecl(context.getTranslationUnitDecl()); 24 visitor_.TraverseDecl(context.getTranslationUnitDecl());
25 if (auto checker = visitor_.ipc_checker()) {
26 checker->Visit(context);
27 }
25 } 28 }
26 29
27 private: 30 private:
28 FindBadConstructsConsumer visitor_; 31 FindBadConstructsConsumer visitor_;
29 }; 32 };
30 33
31 } // namespace 34 } // namespace
32 35
33 FindBadConstructsAction::FindBadConstructsAction() { 36 FindBadConstructsAction::FindBadConstructsAction() {
34 } 37 }
(...skipping 21 matching lines...) Expand all
56 } else if (args[i] == "check-enum-last-value") { 59 } else if (args[i] == "check-enum-last-value") {
57 // TODO(tsepez): Enable this by default once http://crbug.com/356815 60 // TODO(tsepez): Enable this by default once http://crbug.com/356815
58 // and http://crbug.com/356816 are fixed. 61 // and http://crbug.com/356816 are fixed.
59 options_.check_enum_last_value = true; 62 options_.check_enum_last_value = true;
60 } else if (args[i] == "with-ast-visitor") { 63 } else if (args[i] == "with-ast-visitor") {
61 options_.with_ast_visitor = true; 64 options_.with_ast_visitor = true;
62 } else if (args[i] == "check-templates") { 65 } else if (args[i] == "check-templates") {
63 options_.check_templates = true; 66 options_.check_templates = true;
64 } else if (args[i] == "follow-macro-expansion") { 67 } else if (args[i] == "follow-macro-expansion") {
65 options_.follow_macro_expansion = true; 68 options_.follow_macro_expansion = true;
69 } else if (args[i] == "check-ipc") {
70 options_.check_ipc = true;
66 } else { 71 } else {
67 parsed = false; 72 parsed = false;
68 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; 73 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n";
69 } 74 }
70 } 75 }
71 76
72 return parsed; 77 return parsed;
73 } 78 }
74 79
75 } // namespace chrome_checker 80 } // namespace chrome_checker
76 81
77 static FrontendPluginRegistry::Add<chrome_checker::FindBadConstructsAction> X( 82 static FrontendPluginRegistry::Add<chrome_checker::FindBadConstructsAction> X(
78 "find-bad-constructs", 83 "find-bad-constructs",
79 "Finds bad C++ constructs"); 84 "Finds bad C++ constructs");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698