OLD | NEW |
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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 }; | 29 }; |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 FindBadConstructsAction::FindBadConstructsAction() { | 33 FindBadConstructsAction::FindBadConstructsAction() { |
34 } | 34 } |
35 | 35 |
36 std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer( | 36 std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer( |
37 CompilerInstance& instance, | 37 CompilerInstance& instance, |
38 llvm::StringRef ref) { | 38 llvm::StringRef ref) { |
39 if (options_.with_ast_visitor) | 39 return llvm::make_unique<PluginConsumer>(&instance, options_); |
40 return llvm::make_unique<PluginConsumer>(&instance, options_); | |
41 return llvm::make_unique<FindBadConstructsConsumer>(instance, options_); | |
42 } | 40 } |
43 | 41 |
44 bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance, | 42 bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance, |
45 const std::vector<std::string>& args) { | 43 const std::vector<std::string>& args) { |
46 bool parsed = true; | 44 bool parsed = true; |
47 | 45 |
48 for (size_t i = 0; i < args.size() && parsed; ++i) { | 46 for (size_t i = 0; i < args.size() && parsed; ++i) { |
49 if (args[i] == "check-base-classes") { | 47 if (args[i] == "check-base-classes") { |
50 // TODO(rsleevi): Remove this once http://crbug.com/123295 is fixed. | 48 // TODO(rsleevi): Remove this once http://crbug.com/123295 is fixed. |
51 options_.check_base_classes = true; | 49 options_.check_base_classes = true; |
52 } else if (args[i] == "enforce-in-pdf") { | 50 } else if (args[i] == "enforce-in-pdf") { |
53 options_.enforce_in_pdf = true; | 51 options_.enforce_in_pdf = true; |
54 } else if (args[i] == "enforce-in-thirdparty-webkit") { | 52 } else if (args[i] == "enforce-in-thirdparty-webkit") { |
55 options_.enforce_in_thirdparty_webkit = true; | 53 options_.enforce_in_thirdparty_webkit = true; |
56 } else if (args[i] == "check-enum-last-value") { | 54 } else if (args[i] == "check-enum-last-value") { |
57 // TODO(tsepez): Enable this by default once http://crbug.com/356815 | 55 // TODO(tsepez): Enable this by default once http://crbug.com/356815 |
58 // and http://crbug.com/356816 are fixed. | 56 // and http://crbug.com/356816 are fixed. |
59 options_.check_enum_last_value = true; | 57 options_.check_enum_last_value = true; |
60 } else if (args[i] == "with-ast-visitor") { | |
61 options_.with_ast_visitor = true; | |
62 } else if (args[i] == "check-templates") { | 58 } else if (args[i] == "check-templates") { |
63 options_.check_templates = true; | 59 options_.check_templates = true; |
64 } else if (args[i] == "follow-macro-expansion") { | 60 } else if (args[i] == "follow-macro-expansion") { |
65 options_.follow_macro_expansion = true; | 61 options_.follow_macro_expansion = true; |
| 62 } else if (args[i] == "check-implicit-copy-ctors") { |
| 63 options_.check_implicit_copy_ctors = true; |
66 } else { | 64 } else { |
67 parsed = false; | 65 parsed = false; |
68 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; | 66 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; |
69 } | 67 } |
70 } | 68 } |
71 | 69 |
72 return parsed; | 70 return parsed; |
73 } | 71 } |
74 | 72 |
75 } // namespace chrome_checker | 73 } // namespace chrome_checker |
76 | 74 |
77 static FrontendPluginRegistry::Add<chrome_checker::FindBadConstructsAction> X( | 75 static FrontendPluginRegistry::Add<chrome_checker::FindBadConstructsAction> X( |
78 "find-bad-constructs", | 76 "find-bad-constructs", |
79 "Finds bad C++ constructs"); | 77 "Finds bad C++ constructs"); |
OLD | NEW |