From 59e1790c56f7b265bd78c72f8c07274a2eef7fc6 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sat, 21 Nov 2015 13:54:57 +0900 Subject: [PATCH] Bug 1227388 - Finish removing dehydra support. r=mshal Dehydra/Treehydra is unmaintained, broken (iirc), and obsoleted by clang static analysis. We've removed parts of the build system support for it, but not all. This is meant to remove the remains. --- config/static-checking-config.mk | 37 ----- config/static-checking.js | 149 ------------------ configure.in | 18 --- js/src/configure.in | 18 --- js/src/moz.build | 3 - layout/generic/frame-verify.js | 95 ----------- xpcom/tests/moz.build | 3 - xpcom/tests/static-checker/Makefile.in | 146 ----------------- .../static-checker/TestStaticInitAttr.cpp | 5 - .../TestStaticInitConstructor.cpp | 7 - .../static-checker/TestStaticInitGlobal.cpp | 5 - .../TestStaticInitGlobalConst.cpp | 5 - .../static-checker/TestStaticInitStructOK.cpp | 5 - .../static-checker/flow_through_fail.cpp | 16 -- .../static-checker/flow_through_pass.cpp | 20 --- xpcom/tests/static-checker/moz.build | 6 - 16 files changed, 538 deletions(-) delete mode 100644 config/static-checking.js delete mode 100644 layout/generic/frame-verify.js delete mode 100644 xpcom/tests/static-checker/Makefile.in delete mode 100644 xpcom/tests/static-checker/TestStaticInitAttr.cpp delete mode 100644 xpcom/tests/static-checker/TestStaticInitConstructor.cpp delete mode 100644 xpcom/tests/static-checker/TestStaticInitGlobal.cpp delete mode 100644 xpcom/tests/static-checker/TestStaticInitGlobalConst.cpp delete mode 100644 xpcom/tests/static-checker/TestStaticInitStructOK.cpp delete mode 100644 xpcom/tests/static-checker/flow_through_fail.cpp delete mode 100644 xpcom/tests/static-checker/flow_through_pass.cpp delete mode 100644 xpcom/tests/static-checker/moz.build diff --git a/config/static-checking-config.mk b/config/static-checking-config.mk index 449a76f9ae0..747283efd4a 100644 --- a/config/static-checking-config.mk +++ b/config/static-checking-config.mk @@ -5,43 +5,6 @@ # The entire tree should be subject to static analysis using the XPCOM # script. Additional scripts may be added by specific subdirectories. -DEHYDRA_SCRIPT = $(topsrcdir)/config/static-checking.js - -ifndef JS_STANDALONE -DEHYDRA_MODULES = \ - $(topsrcdir)/xpcom/analysis/final.js \ - $(topsrcdir)/xpcom/analysis/must-override.js \ - $(NULL) - -TREEHYDRA_MODULES = \ - $(topsrcdir)/xpcom/analysis/outparams.js \ - $(topsrcdir)/xpcom/analysis/stack.js \ - $(topsrcdir)/xpcom/analysis/flow.js \ - $(topsrcdir)/xpcom/analysis/static-init.js \ - $(topsrcdir)/layout/generic/frame-verify.js \ - $(NULL) -endif - -TREEHYDRA_MODULES += \ - $(topsrcdir)/js/src/jsstack.js \ - $(NULL) - -DEHYDRA_ARG_PREFIX=-fplugin-arg-gcc_treehydra- - -DEHYDRA_ARGS = \ - $(DEHYDRA_ARG_PREFIX)script=$(DEHYDRA_SCRIPT) \ - $(DEHYDRA_ARG_PREFIX)topsrcdir=$(topsrcdir) \ - $(DEHYDRA_ARG_PREFIX)objdir=$(DEPTH) \ - $(DEHYDRA_ARG_PREFIX)dehydra-modules=$(subst $(NULL) ,$(COMMA),$(strip $(DEHYDRA_MODULES))) \ - $(DEHYDRA_ARG_PREFIX)treehydra-modules=$(subst $(NULL) ,$(COMMA),$(strip $(TREEHYDRA_MODULES))) \ - $(NULL) - -DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) $(DEHYDRA_ARGS) - -ifdef DEHYDRA_PATH -OS_CXXFLAGS += $(DEHYDRA_FLAGS) -endif - ifdef ENABLE_CLANG_PLUGIN CLANG_PLUGIN := $(DEPTH)/build/clang-plugin/$(DLL_PREFIX)clang-plugin$(DLL_SUFFIX) OS_CXXFLAGS += -Xclang -load -Xclang $(CLANG_PLUGIN) -Xclang -add-plugin -Xclang moz-check diff --git a/config/static-checking.js b/config/static-checking.js deleted file mode 100644 index 354ccf2c0ab..00000000000 --- a/config/static-checking.js +++ /dev/null @@ -1,149 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/** - * A script for GCC-dehydra to analyze the Mozilla codebase and catch - * patterns that are incorrect, but which cannot be detected by a compiler. */ - -/** - * Activate Treehydra outparams analysis if running in Treehydra. - */ - -function treehydra_enabled() { - return this.hasOwnProperty('TREE_CODE'); -} - -sys.include_path.push(options.topsrcdir); - -include('string-format.js'); - -var modules = []; - -function LoadModules(modulelist) -{ - if (modulelist == "") - return; - - let modulenames = modulelist.split(','); - for (let modulename of modulenames) { - let module = { __proto__: this }; - include(modulename, module); - modules.push(module); - } -} - -LoadModules(options['dehydra-modules']); -if (treehydra_enabled()) - LoadModules(options['treehydra-modules']); - -function process_type(c) -{ - for (let module of modules) - if (module.hasOwnProperty('process_type')) - module.process_type(c); -} - -function hasAttribute(c, attrname) -{ - var attr; - - if (c.attributes === undefined) - return false; - - for (var key in c.attributes) { - attr = c.attributes[key]; - if (attr.name == 'user' && attr.value[0] == attrname) - return true; - } - - return false; -} - -// This is useful for detecting method overrides -function signaturesMatch(m1, m2) -{ - if (m1.shortName != m2.shortName) - return false; - - if ((!!m1.isVirtual) != (!!m2.isVirtual)) - return false; - - if (m1.isStatic != m2.isStatic) - return false; - - let p1 = m1.type.parameters; - let p2 = m2.type.parameters; - - if (p1.length != p2.length) - return false; - - for (let i = 0; i < p1.length; ++i) - if (!params_match(p1[i], p2[i])) - return false; - - return true; -} - -function params_match(p1, p2) -{ - [p1, p2] = unwrap_types(p1, p2); - - for (let i in p1) - if (i == "type" && !types_match(p1.type, p2.type)) - return false; - else if (i != "type" && p1[i] !== p2[i]) - return false; - - for (let i in p2) - if (!(i in p1)) - return false; - - return true; -} - -function types_match(t1, t2) -{ - if (!t1 || !t2) - return false; - - [t1, t2] = unwrap_types(t1, t2); - - return t1 === t2; -} - -function unwrap_types(t1, t2) -{ - while (t1.variantOf) - t1 = t1.variantOf; - - while (t2.variantOf) - t2 = t2.variantOf; - - return [t1, t2]; -} - -const forward_functions = [ - 'process_type', - 'process_tree_type', - 'process_decl', - 'process_tree_decl', - 'process_function', - 'process_tree', - 'process_cp_pre_genericize', - 'input_end' -]; - -function setup_forwarding(n) -{ - this[n] = function() { - for (let module of modules) { - if (module.hasOwnProperty(n)) { - module[n].apply(this, arguments); - } - } - } -} - -for (let n of forward_functions) - setup_forwarding(n); diff --git a/configure.in b/configure.in index c788a149596..0e367380a79 100644 --- a/configure.in +++ b/configure.in @@ -7337,24 +7337,6 @@ fi AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS) export MOZ_GLUE_WRAP_LDFLAGS -dnl ======================================================== -dnl = Enable static checking using gcc-dehydra -dnl ======================================================== - -MOZ_ARG_WITH_STRING(static-checking, -[ --with-static-checking=path/to/gcc_dehydra.so - Enable static checking of code using GCC-dehydra], - DEHYDRA_PATH=$withval, - DEHYDRA_PATH= ) - -if test -n "$DEHYDRA_PATH"; then - if test ! -f "$DEHYDRA_PATH"; then - AC_MSG_ERROR([The dehydra plugin is not at the specified path.]) - fi - AC_DEFINE(NS_STATIC_CHECKING) -fi -AC_SUBST(DEHYDRA_PATH) - dnl ======================================================== dnl = Enable using the clang plugin to build dnl ======================================================== diff --git a/js/src/configure.in b/js/src/configure.in index 5eb9da1e553..2c5a135f05b 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -3293,24 +3293,6 @@ if test -n "$JS_OOM_BREAKPOINT"; then AC_DEFINE(JS_OOM_BREAKPOINT) fi -dnl ======================================================== -dnl = Enable static checking using gcc-dehydra -dnl ======================================================== - -MOZ_ARG_WITH_STRING(static-checking, -[ --with-static-checking=path/to/gcc_dehydra.so - Enable static checking of code using GCC-dehydra], - DEHYDRA_PATH=$withval, - DEHYDRA_PATH= ) - -if test -n "$DEHYDRA_PATH"; then - if test ! -f "$DEHYDRA_PATH"; then - AC_MSG_ERROR([The dehydra plugin is not at the specified path.]) - fi - AC_DEFINE(NS_STATIC_CHECKING) -fi -AC_SUBST(DEHYDRA_PATH) - dnl ======================================================== dnl = Enable using the clang plugin to build dnl ======================================================== diff --git a/js/src/moz.build b/js/src/moz.build index 07b4105de2d..803737c4b8f 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -50,9 +50,6 @@ with Files('../public/TrackedOptimizationInfo.h'): BUG_COMPONENT = component_jit -if CONFIG['DEHYDRA_PATH']: - DIRS += ['analysis-tests'] - if CONFIG['JS_BUNDLED_EDITLINE']: DIRS += ['editline'] diff --git a/layout/generic/frame-verify.js b/layout/generic/frame-verify.js deleted file mode 100644 index b5ad0939517..00000000000 --- a/layout/generic/frame-verify.js +++ /dev/null @@ -1,95 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/** - * graph-frameclasses.js: a dehydra script to collect information about - * the class hierarchy of frame types. - */ - -function inheritsFrom(t, baseName) -{ - let name = t.name; - if (name == baseName) - return true; - - for (let base of t.bases) - if (inheritsFrom(base.type, baseName)) - return true; - - return false; -} - -var output = []; - -function process_type(t) -{ - if ((t.kind == "class" || t.kind == "struct")) { - if (!t.isIncomplete && inheritsFrom(t, 'nsIFrame')) { - if (inheritsFrom(t, 'nsISupports')) - warning("nsIFrame derivative %s inherits from nsISupports but is not refcounted.".format(t.name), t.loc); - - let nonFrameBases = []; - - output.push('CLASS-DEF: %s'.format(t.name)); - - for (let base of t.bases) { - if (inheritsFrom(base.type, 'nsIFrame')) { - output.push('%s -> %s;'.format(base.type.name, t.name)); - } - else if (base.type.name != 'nsQueryFrame') { - nonFrameBases.push(base.type.name); - } - } - - output.push('%s [label="%s%s"];'.format(t.name, t.name, - nonFrameBases.map(b => "\\n(%s)".format(b)).join(''))); - } - } -} - -var frameIIDRE = /::kFrameIID$/; -var queryFrameRE = /^do_QueryFrame::operator/; - -/* A list of class names T that have do_QueryFrame used */ -var needIDs = []; - -/* A map of class names that have a kFrameIID declared */ -var haveIDs = {}; - -// We match up needIDs with haveIDs at the end because static variables are -// not present in the .members array of a type - -function process_tree_decl(d) -{ - d = dehydra_convert(d); - - if (d.name && frameIIDRE.exec(d.name)) { - haveIDs[d.memberOf.name] = 1; - } -} - -function process_cp_pre_genericize(d) -{ - d = dehydra_convert(d); - if (queryFrameRE.exec(d.name) && d.template === undefined) { - let templtype = d.type.type.type; - while (templtype.typedef !== undefined) - templtype = templtype.typedef; - - needIDs.push([templtype.name, d.loc]); - } -} - -function input_end() -{ - for (let [name, loc] of needIDs) { - if (!haveIDs.hasOwnProperty(name)) { - error("nsQueryFrame<%s> found, but %s::kFrameIID is not declared".format(name, name), loc); - } - } - - if (output.length > 0) { - write_file(sys.aux_base_name + '.framedata', output.join('\n')); - } -} diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index 7f0019efd77..b369b6bafdf 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -15,9 +15,6 @@ TEST_DIRS += [ if CONFIG['OS_ARCH'] == 'WINNT': TEST_DIRS += ['windows'] -if CONFIG['DEHYDRA_PATH']: - TEST_DIRS += ['static-checker'] - EXPORTS.testing += [ 'TestHarness.h', ] diff --git a/xpcom/tests/static-checker/Makefile.in b/xpcom/tests/static-checker/Makefile.in deleted file mode 100644 index c394424642c..00000000000 --- a/xpcom/tests/static-checker/Makefile.in +++ /dev/null @@ -1,146 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -OUTPARAMS_WARNING_TESTCASES = \ - e1.cpp \ - e4.cpp \ - e6.cpp \ - e7.cpp \ - e8.cpp \ - e9.cpp \ - e10.cpp \ - e11.cpp \ - e12.cpp \ - e13.cpp \ - $(NULL) - -OUTPARAMS_NS_FAILED_TESTCASES = \ - e2.cpp \ - e5.cpp \ - $(NULL) - -OUTPARAMS_PASS_TESTCASES = \ - o1.cpp \ - o2.cpp \ - o3.cpp \ - o4.cpp \ - o5.cpp \ - o6.cpp \ - o7.cpp \ - o8.cpp \ - o9.cpp \ - o10.cpp \ - o11.cpp \ - o12.cpp \ - o13.cpp \ - o14.cpp \ - o15.cpp \ - o16.cpp \ - onull.cpp \ - onull2.cpp \ - opmember.cpp \ - $(NULL) - -FLOW_PASS_TESTCASES = \ - flow_through_pass.cpp - -FLOW_FAILURE_TESTCASES = \ - flow_through_fail.cpp - -MUST_OVERRIDE_PASS_TESTCASES = \ - OverrideOK1.cpp \ - OverrideOK2.cpp \ - OverrideOK3-NamespaceTypedef.cpp \ - $(NULL) - -MUST_OVERRIDE_FAILURE_TESTCASES = \ - OverrideFail1.cpp \ - OverrideFail2.cpp \ - OverrideFail3.cpp \ - OverrideFail4.cpp \ - $(NULL) - -OVERRIDE_PASS_TESTCASES = \ - override-pass.cpp \ - override-namespace-typedef.cpp \ - $(NULL) - -OVERRIDE_FAILURE_TESTCASES = \ - override-global.cpp \ - override-signature.cpp \ - override-static.cpp \ - override-virtual.cpp \ - $(NULL) - -STATIC_INIT_PASS_TESTCASES = \ - TestStaticInitStructOK.cpp \ - $(NULL) - -STATIC_INIT_WARNING_TESTCASES = \ - TestStaticInitAttr.cpp \ - TestStaticInitConstructor.cpp \ - TestStaticInitGlobal.cpp \ - TestStaticInitGlobalConst.cpp \ - $(NULL) - -STATIC_FAILURE_TESTCASES = \ - $(FLOW_FAILURE_TESTCASES) \ - $(MUST_OVERRIDE_FAILURE_TESTCASES) \ - $(OVERRIDE_FAILURE_TESTCASES) \ - $(NULL) - -STATIC_WARNING_TESTCASES = \ - $(OUTPARAMS_WARNING_TESTCASES) \ - $(STATIC_INIT_WARNING_TESTCASES) \ - $(NULL) - -STATIC_PASS_TESTCASES = \ - $(OUTPARAMS_NS_FAILED_TESTCASES) \ - $(OUTPARAMS_PASS_TESTCASES) \ - $(FLOW_PASS_TESTCASES) \ - $(MUST_OVERRIDE_PASS_TESTCASES) \ - $(OVERRIDE_PASS_TESTCASES) \ - $(STATIC_INIT_PASS_TESTCASES) \ - $(NULL) - - -include $(topsrcdir)/config/rules.mk - -# We want to compile each file and invert the result to ensure that -# compilation failed. -check:: \ - $(STATIC_FAILURE_TESTCASES:.cpp=.s-fail) \ - $(STATIC_WARNING_TESTCASES:.cpp=.s-warn) \ - $(STATIC_PASS_TESTCASES:.cpp=.s-pass) - -%.s-fail: %.cpp $(GLOBAL_DEPS) $(DEHYDRA_SCRIPTS) $(call mkdir_deps,$(MDDEPDIR)) - @printf 'Compiling $($(*F).errlog 2>&1; then \ - printf 'fail:\nerror: compilation of $($(*F).errlog 2>&1; then \ - printf 'fail:\nerror: compilation of $($(*F).werrlog 2>&1; then \ - printf 'ok.\n'; \ - else \ - printf 'fail:\nerror: compilation of $($(*F).errlog 2>&1; then \ - printf 'ok.\n'; \ - else \ - printf 'fail:\nerror: compilation of $(