OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This clang plugin checks various invariants of the Blink garbage |
| 6 // collection infrastructure. |
| 7 // |
| 8 // Errors are described at: |
| 9 // http://www.chromium.org/developers/blink-gc-plugin-errors |
| 10 |
| 11 #include "BlinkGCPluginConsumer.h" |
| 12 #include "BlinkGCPluginOptions.h" |
| 13 #include "Config.h" |
| 14 |
| 15 #include "clang/Frontend/CompilerInstance.h" |
| 16 #include "clang/Frontend/FrontendPluginRegistry.h" |
| 17 |
| 18 using namespace clang; |
| 19 |
| 20 class BlinkGCPluginAction : public PluginASTAction { |
| 21 public: |
| 22 BlinkGCPluginAction() {} |
| 23 |
| 24 protected: |
| 25 // Overridden from PluginASTAction: |
| 26 virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( |
| 27 CompilerInstance& instance, |
| 28 llvm::StringRef ref) { |
| 29 return llvm::make_unique<BlinkGCPluginConsumer>(instance, options_); |
| 30 } |
| 31 |
| 32 virtual bool ParseArgs(const CompilerInstance& instance, |
| 33 const std::vector<std::string>& args) { |
| 34 bool parsed = true; |
| 35 |
| 36 for (size_t i = 0; i < args.size() && parsed; ++i) { |
| 37 if (args[i] == "enable-oilpan") { |
| 38 options_.enable_oilpan = true; |
| 39 } else if (args[i] == "dump-graph") { |
| 40 options_.dump_graph = true; |
| 41 } else if (args[i] == "warn-raw-ptr") { |
| 42 options_.warn_raw_ptr = true; |
| 43 } else if (args[i] == "warn-unneeded-finalizer") { |
| 44 options_.warn_unneeded_finalizer = true; |
| 45 } else { |
| 46 parsed = false; |
| 47 llvm::errs() << "Unknown blink-gc-plugin argument: " << args[i] << "\n"; |
| 48 } |
| 49 } |
| 50 |
| 51 return parsed; |
| 52 } |
| 53 |
| 54 private: |
| 55 BlinkGCPluginOptions options_; |
| 56 }; |
| 57 |
| 58 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( |
| 59 "blink-gc-plugin", |
| 60 "Check Blink GC invariants"); |
OLD | NEW |