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/Frontend/FrontendPluginRegistry.h" | 7 #include "clang/Frontend/FrontendPluginRegistry.h" |
8 | 8 |
9 #include "FindBadConstructsConsumer.h" | 9 #include "FindBadConstructsConsumer.h" |
10 | 10 |
11 using namespace clang; | 11 using namespace clang; |
12 | 12 |
13 namespace chrome_checker { | 13 namespace chrome_checker { |
14 | 14 |
15 FindBadConstructsAction::FindBadConstructsAction() { | 15 FindBadConstructsAction::FindBadConstructsAction() { |
16 } | 16 } |
17 | 17 |
18 std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer( | 18 std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer( |
19 CompilerInstance& instance, | 19 CompilerInstance& instance, |
20 llvm::StringRef ref) { | 20 llvm::StringRef ref) { |
21 return llvm::make_unique<FindBadConstructsConsumer>(instance, options_); | 21 return llvm::make_unique<FindBadConstructsConsumer>(instance, options_); |
22 } | 22 } |
23 | 23 |
24 bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance, | 24 bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance, |
25 const std::vector<std::string>& args) { | 25 const std::vector<std::string>& args) { |
26 bool parsed = true; | 26 bool parsed = true; |
27 | 27 |
28 for (size_t i = 0; i < args.size() && parsed; ++i) { | 28 for (size_t i = 0; i < args.size() && parsed; ++i) { |
29 if (args[i] == "skip-virtuals-in-implementations") { | 29 if (args[i] == "check-base-classes") { |
30 // TODO(rsleevi): Remove this once http://crbug.com/115047 is fixed. | |
31 options_.check_virtuals_in_implementations = false; | |
32 } else if (args[i] == "check-base-classes") { | |
33 // TODO(rsleevi): Remove this once http://crbug.com/123295 is fixed. | 30 // TODO(rsleevi): Remove this once http://crbug.com/123295 is fixed. |
34 options_.check_base_classes = true; | 31 options_.check_base_classes = true; |
35 } else if (args[i] == "check-weak-ptr-factory-order") { | 32 } else if (args[i] == "check-weak-ptr-factory-order") { |
36 // TODO(dmichael): Remove this once http://crbug.com/303818 is fixed. | 33 // TODO(dmichael): Remove this once http://crbug.com/303818 is fixed. |
37 options_.check_weak_ptr_factory_order = true; | 34 options_.check_weak_ptr_factory_order = true; |
38 } else if (args[i] == "check-enum-last-value") { | 35 } else if (args[i] == "check-enum-last-value") { |
39 // TODO(tsepez): Enable this by default once http://crbug.com/356815 | 36 // TODO(tsepez): Enable this by default once http://crbug.com/356815 |
40 // and http://crbug.com/356816 are fixed. | 37 // and http://crbug.com/356816 are fixed. |
41 options_.check_enum_last_value = true; | 38 options_.check_enum_last_value = true; |
42 } else { | 39 } else { |
43 parsed = false; | 40 parsed = false; |
44 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; | 41 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; |
45 } | 42 } |
46 } | 43 } |
47 | 44 |
48 return parsed; | 45 return parsed; |
49 } | 46 } |
50 | 47 |
51 } // namespace chrome_checker | 48 } // namespace chrome_checker |
52 | 49 |
53 static FrontendPluginRegistry::Add<chrome_checker::FindBadConstructsAction> X( | 50 static FrontendPluginRegistry::Add<chrome_checker::FindBadConstructsAction> X( |
54 "find-bad-constructs", | 51 "find-bad-constructs", |
55 "Finds bad C++ constructs"); | 52 "Finds bad C++ constructs"); |
OLD | NEW |