| 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 |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 DiagnosticsEngine::Note, kOverriddenNonVirtualTraceNote); | 858 DiagnosticsEngine::Note, kOverriddenNonVirtualTraceNote); |
| 859 diag_manual_dispatch_method_note_ = diagnostic_.getCustomDiagID( | 859 diag_manual_dispatch_method_note_ = diagnostic_.getCustomDiagID( |
| 860 DiagnosticsEngine::Note, kManualDispatchMethodNote); | 860 DiagnosticsEngine::Note, kManualDispatchMethodNote); |
| 861 } | 861 } |
| 862 | 862 |
| 863 void HandleTranslationUnit(ASTContext& context) override { | 863 void HandleTranslationUnit(ASTContext& context) override { |
| 864 CollectVisitor visitor; | 864 CollectVisitor visitor; |
| 865 visitor.TraverseDecl(context.getTranslationUnitDecl()); | 865 visitor.TraverseDecl(context.getTranslationUnitDecl()); |
| 866 | 866 |
| 867 if (options_.dump_graph) { | 867 if (options_.dump_graph) { |
| 868 string err; | 868 std::error_code err; |
| 869 // TODO: Make createDefaultOutputFile or a shorter createOutputFile work. | 869 // TODO: Make createDefaultOutputFile or a shorter createOutputFile work. |
| 870 json_ = JsonWriter::from(instance_.createOutputFile( | 870 json_ = JsonWriter::from(instance_.createOutputFile( |
| 871 "", // OutputPath | 871 "", // OutputPath |
| 872 err, // Errors | 872 err, // Errors |
| 873 true, // Binary | 873 true, // Binary |
| 874 true, // RemoveFileOnSignal | 874 true, // RemoveFileOnSignal |
| 875 instance_.getFrontendOpts().OutputFile, // BaseInput | 875 instance_.getFrontendOpts().OutputFile, // BaseInput |
| 876 "graph.json", // Extension | 876 "graph.json", // Extension |
| 877 false, // UseTemporary | 877 false, // UseTemporary |
| 878 false, // CreateMissingDirectories | 878 false, // CreateMissingDirectories |
| 879 0, // ResultPathName | 879 0, // ResultPathName |
| 880 0)); // TempPathName | 880 0)); // TempPathName |
| 881 if (err.empty() && json_) { | 881 if (!err && json_) { |
| 882 json_->OpenList(); | 882 json_->OpenList(); |
| 883 } else { | 883 } else { |
| 884 json_ = 0; | 884 json_ = 0; |
| 885 llvm::errs() | 885 llvm::errs() |
| 886 << "[blink-gc] " | 886 << "[blink-gc] " |
| 887 << "Failed to create an output file for the object graph.\n"; | 887 << "Failed to create an output file for the object graph.\n"; |
| 888 } | 888 } |
| 889 } | 889 } |
| 890 | 890 |
| 891 for (RecordVector::iterator it = visitor.record_decls().begin(); | 891 for (RecordVector::iterator it = visitor.record_decls().begin(); |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 RecordCache cache_; | 1837 RecordCache cache_; |
| 1838 JsonWriter* json_; | 1838 JsonWriter* json_; |
| 1839 }; | 1839 }; |
| 1840 | 1840 |
| 1841 class BlinkGCPluginAction : public PluginASTAction { | 1841 class BlinkGCPluginAction : public PluginASTAction { |
| 1842 public: | 1842 public: |
| 1843 BlinkGCPluginAction() {} | 1843 BlinkGCPluginAction() {} |
| 1844 | 1844 |
| 1845 protected: | 1845 protected: |
| 1846 // Overridden from PluginASTAction: | 1846 // Overridden from PluginASTAction: |
| 1847 virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance, | 1847 virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( |
| 1848 llvm::StringRef ref) { | 1848 CompilerInstance& instance, |
| 1849 return new BlinkGCPluginConsumer(instance, options_); | 1849 llvm::StringRef ref) { |
| 1850 return llvm::make_unique<BlinkGCPluginConsumer>(instance, options_); |
| 1850 } | 1851 } |
| 1851 | 1852 |
| 1852 virtual bool ParseArgs(const CompilerInstance& instance, | 1853 virtual bool ParseArgs(const CompilerInstance& instance, |
| 1853 const std::vector<string>& args) { | 1854 const std::vector<string>& args) { |
| 1854 bool parsed = true; | 1855 bool parsed = true; |
| 1855 | 1856 |
| 1856 for (size_t i = 0; i < args.size() && parsed; ++i) { | 1857 for (size_t i = 0; i < args.size() && parsed; ++i) { |
| 1857 if (args[i] == "enable-oilpan") { | 1858 if (args[i] == "enable-oilpan") { |
| 1858 options_.enable_oilpan = true; | 1859 options_.enable_oilpan = true; |
| 1859 } else if (args[i] == "dump-graph") { | 1860 } else if (args[i] == "dump-graph") { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1873 | 1874 |
| 1874 private: | 1875 private: |
| 1875 BlinkGCPluginOptions options_; | 1876 BlinkGCPluginOptions options_; |
| 1876 }; | 1877 }; |
| 1877 | 1878 |
| 1878 } // namespace | 1879 } // namespace |
| 1879 | 1880 |
| 1880 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( | 1881 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( |
| 1881 "blink-gc-plugin", | 1882 "blink-gc-plugin", |
| 1882 "Check Blink GC invariants"); | 1883 "Check Blink GC invariants"); |
| OLD | NEW |