OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 // Checks that are implemented: |
| 9 // [currently none] |
| 10 |
| 11 #include "clang/AST/AST.h" |
| 12 #include "clang/AST/ASTConsumer.h" |
| 13 #include "clang/Frontend/CompilerInstance.h" |
| 14 #include "clang/Frontend/FrontendPluginRegistry.h" |
| 15 |
| 16 using namespace clang; |
| 17 using std::string; |
| 18 |
| 19 namespace { |
| 20 |
| 21 struct BlinkGCPluginOptions { |
| 22 BlinkGCPluginOptions() { |
| 23 } |
| 24 }; |
| 25 |
| 26 // Main class containing checks for various invariants of the Blink |
| 27 // garbage collection infrastructure. |
| 28 class BlinkGCPluginConsumer : public ASTConsumer { |
| 29 public: |
| 30 BlinkGCPluginConsumer(CompilerInstance& instance, |
| 31 const BlinkGCPluginOptions& options) { |
| 32 } |
| 33 |
| 34 virtual void HandleTranslationUnit(ASTContext& context) { |
| 35 // FIXME: implement consistency checks. |
| 36 } |
| 37 }; |
| 38 |
| 39 |
| 40 class BlinkGCPluginAction : public PluginASTAction { |
| 41 public: |
| 42 BlinkGCPluginAction() { |
| 43 } |
| 44 |
| 45 protected: |
| 46 // Overridden from PluginASTAction: |
| 47 virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance, |
| 48 llvm::StringRef ref) { |
| 49 return new BlinkGCPluginConsumer(instance, options_); |
| 50 } |
| 51 |
| 52 virtual bool ParseArgs(const CompilerInstance& instance, |
| 53 const std::vector<string>& args) { |
| 54 bool parsed = true; |
| 55 |
| 56 for (size_t i = 0; i < args.size() && parsed; ++i) { |
| 57 parsed = false; |
| 58 llvm::errs() << "Unknown blink-gc-plugin argument: " << args[i] << "\n"; |
| 59 } |
| 60 |
| 61 return parsed; |
| 62 } |
| 63 |
| 64 private: |
| 65 BlinkGCPluginOptions options_; |
| 66 }; |
| 67 |
| 68 } // namespace |
| 69 |
| 70 static FrontendPluginRegistry::Add<BlinkGCPluginAction> |
| 71 X("blink-gc-plugin", "Check Blink GC invariants"); |
OLD | NEW |