OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This clang plugin checks various invariants of the Blink garbage | 5 // This clang plugin checks various invariants of the Blink garbage |
6 // collection infrastructure. | 6 // collection infrastructure. |
7 // | 7 // |
8 // Errors are described at: | 8 // Errors are described at: |
9 // http://www.chromium.org/developers/blink-gc-plugin-errors | 9 // http://www.chromium.org/developers/blink-gc-plugin-errors |
10 | 10 |
11 #include "BlinkGCPluginConsumer.h" | 11 #include "BlinkGCPluginConsumer.h" |
12 #include "BlinkGCPluginOptions.h" | 12 #include "BlinkGCPluginOptions.h" |
13 #include "Config.h" | 13 #include "Config.h" |
14 | 14 |
15 #include "clang/Frontend/CompilerInstance.h" | 15 #include "clang/Frontend/CompilerInstance.h" |
16 #include "clang/Frontend/FrontendPluginRegistry.h" | 16 #include "clang/Frontend/FrontendPluginRegistry.h" |
17 | 17 |
18 using namespace clang; | 18 using namespace clang; |
19 | 19 |
20 class BlinkGCPluginAction : public PluginASTAction { | 20 class BlinkGCPluginAction : public PluginASTAction { |
21 public: | 21 public: |
22 BlinkGCPluginAction() {} | 22 BlinkGCPluginAction() {} |
23 | 23 |
24 protected: | 24 protected: |
25 // Overridden from PluginASTAction: | 25 // Overridden from PluginASTAction: |
26 virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( | 26 std::unique_ptr<ASTConsumer> CreateASTConsumer( |
27 CompilerInstance& instance, | 27 CompilerInstance& instance, |
28 llvm::StringRef ref) { | 28 llvm::StringRef ref) override { |
29 return llvm::make_unique<BlinkGCPluginConsumer>(instance, options_); | 29 return llvm::make_unique<BlinkGCPluginConsumer>(instance, options_); |
30 } | 30 } |
31 | 31 |
32 virtual bool ParseArgs(const CompilerInstance&, | 32 bool ParseArgs(const CompilerInstance&, |
33 const std::vector<std::string>& args) { | 33 const std::vector<std::string>& args) override { |
sof
2016/12/20 13:51:54
misindented.
dcheng
2016/12/20 17:31:18
Done.
| |
34 for (const auto& arg : args) { | 34 for (const auto& arg : args) { |
35 if (arg == "dump-graph") { | 35 if (arg == "dump-graph") { |
36 options_.dump_graph = true; | 36 options_.dump_graph = true; |
37 } else if (arg == "warn-unneeded-finalizer") { | 37 } else if (arg == "warn-unneeded-finalizer") { |
38 options_.warn_unneeded_finalizer = true; | 38 options_.warn_unneeded_finalizer = true; |
39 } else if (arg == "use-chromium-style-naming") { | |
40 options_.use_chromium_style_naming = true; | |
39 } else { | 41 } else { |
40 llvm::errs() << "Unknown blink-gc-plugin argument: " << arg << "\n"; | 42 llvm::errs() << "Unknown blink-gc-plugin argument: " << arg << "\n"; |
41 return false; | 43 return false; |
42 } | 44 } |
43 } | 45 } |
44 return true; | 46 return true; |
45 } | 47 } |
46 | 48 |
47 private: | 49 private: |
48 BlinkGCPluginOptions options_; | 50 BlinkGCPluginOptions options_; |
49 }; | 51 }; |
50 | 52 |
51 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( | 53 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( |
52 "blink-gc-plugin", | 54 "blink-gc-plugin", |
53 "Check Blink GC invariants"); | 55 "Check Blink GC invariants"); |
OLD | NEW |