gecko/config/check_spidermonkey_style.py
Jan de Mooij 30911640d3 Bug 902908 - Rename js/src/ion to js/src/jit. r=luke
--HG--
rename : js/src/ion/AliasAnalysis.cpp => js/src/jit/AliasAnalysis.cpp
rename : js/src/ion/AliasAnalysis.h => js/src/jit/AliasAnalysis.h
rename : js/src/ion/AsmJS.cpp => js/src/jit/AsmJS.cpp
rename : js/src/ion/AsmJS.h => js/src/jit/AsmJS.h
rename : js/src/ion/AsmJSLink.cpp => js/src/jit/AsmJSLink.cpp
rename : js/src/ion/AsmJSLink.h => js/src/jit/AsmJSLink.h
rename : js/src/ion/AsmJSModule.cpp => js/src/jit/AsmJSModule.cpp
rename : js/src/ion/AsmJSModule.h => js/src/jit/AsmJSModule.h
rename : js/src/ion/AsmJSSignalHandlers.cpp => js/src/jit/AsmJSSignalHandlers.cpp
rename : js/src/ion/AsmJSSignalHandlers.h => js/src/jit/AsmJSSignalHandlers.h
rename : js/src/ion/BacktrackingAllocator.cpp => js/src/jit/BacktrackingAllocator.cpp
rename : js/src/ion/BacktrackingAllocator.h => js/src/jit/BacktrackingAllocator.h
rename : js/src/ion/Bailouts.cpp => js/src/jit/Bailouts.cpp
rename : js/src/ion/Bailouts.h => js/src/jit/Bailouts.h
rename : js/src/ion/BaselineBailouts.cpp => js/src/jit/BaselineBailouts.cpp
rename : js/src/ion/BaselineCompiler.cpp => js/src/jit/BaselineCompiler.cpp
rename : js/src/ion/BaselineCompiler.h => js/src/jit/BaselineCompiler.h
rename : js/src/ion/BaselineFrame-inl.h => js/src/jit/BaselineFrame-inl.h
rename : js/src/ion/BaselineFrame.cpp => js/src/jit/BaselineFrame.cpp
rename : js/src/ion/BaselineFrame.h => js/src/jit/BaselineFrame.h
rename : js/src/ion/BaselineFrameInfo.cpp => js/src/jit/BaselineFrameInfo.cpp
rename : js/src/ion/BaselineFrameInfo.h => js/src/jit/BaselineFrameInfo.h
rename : js/src/ion/BaselineHelpers.h => js/src/jit/BaselineHelpers.h
rename : js/src/ion/BaselineIC.cpp => js/src/jit/BaselineIC.cpp
rename : js/src/ion/BaselineIC.h => js/src/jit/BaselineIC.h
rename : js/src/ion/BaselineInspector.cpp => js/src/jit/BaselineInspector.cpp
rename : js/src/ion/BaselineInspector.h => js/src/jit/BaselineInspector.h
rename : js/src/ion/BaselineJIT.cpp => js/src/jit/BaselineJIT.cpp
rename : js/src/ion/BaselineJIT.h => js/src/jit/BaselineJIT.h
rename : js/src/ion/BaselineRegisters.h => js/src/jit/BaselineRegisters.h
rename : js/src/ion/BitSet.cpp => js/src/jit/BitSet.cpp
rename : js/src/ion/BitSet.h => js/src/jit/BitSet.h
rename : js/src/ion/BytecodeAnalysis.cpp => js/src/jit/BytecodeAnalysis.cpp
rename : js/src/ion/BytecodeAnalysis.h => js/src/jit/BytecodeAnalysis.h
rename : js/src/ion/C1Spewer.cpp => js/src/jit/C1Spewer.cpp
rename : js/src/ion/C1Spewer.h => js/src/jit/C1Spewer.h
rename : js/src/ion/CodeGenerator.cpp => js/src/jit/CodeGenerator.cpp
rename : js/src/ion/CodeGenerator.h => js/src/jit/CodeGenerator.h
rename : js/src/ion/CompactBuffer.h => js/src/jit/CompactBuffer.h
rename : js/src/ion/CompileInfo-inl.h => js/src/jit/CompileInfo-inl.h
rename : js/src/ion/CompileInfo.h => js/src/jit/CompileInfo.h
rename : js/src/ion/CompilerRoot.h => js/src/jit/CompilerRoot.h
rename : js/src/ion/EdgeCaseAnalysis.cpp => js/src/jit/EdgeCaseAnalysis.cpp
rename : js/src/ion/EdgeCaseAnalysis.h => js/src/jit/EdgeCaseAnalysis.h
rename : js/src/ion/EffectiveAddressAnalysis.cpp => js/src/jit/EffectiveAddressAnalysis.cpp
rename : js/src/ion/EffectiveAddressAnalysis.h => js/src/jit/EffectiveAddressAnalysis.h
rename : js/src/ion/ExecutionModeInlines.h => js/src/jit/ExecutionModeInlines.h
rename : js/src/ion/FixedList.h => js/src/jit/FixedList.h
rename : js/src/ion/InlineList.h => js/src/jit/InlineList.h
rename : js/src/ion/Ion.cpp => js/src/jit/Ion.cpp
rename : js/src/ion/Ion.h => js/src/jit/Ion.h
rename : js/src/ion/IonAllocPolicy.h => js/src/jit/IonAllocPolicy.h
rename : js/src/ion/IonAnalysis.cpp => js/src/jit/IonAnalysis.cpp
rename : js/src/ion/IonAnalysis.h => js/src/jit/IonAnalysis.h
rename : js/src/ion/IonBuilder.cpp => js/src/jit/IonBuilder.cpp
rename : js/src/ion/IonBuilder.h => js/src/jit/IonBuilder.h
rename : js/src/ion/IonCaches.cpp => js/src/jit/IonCaches.cpp
rename : js/src/ion/IonCaches.h => js/src/jit/IonCaches.h
rename : js/src/ion/IonCode.h => js/src/jit/IonCode.h
rename : js/src/ion/IonCompartment.h => js/src/jit/IonCompartment.h
rename : js/src/ion/IonFrameIterator-inl.h => js/src/jit/IonFrameIterator-inl.h
rename : js/src/ion/IonFrameIterator.h => js/src/jit/IonFrameIterator.h
rename : js/src/ion/IonFrames-inl.h => js/src/jit/IonFrames-inl.h
rename : js/src/ion/IonFrames.cpp => js/src/jit/IonFrames.cpp
rename : js/src/ion/IonFrames.h => js/src/jit/IonFrames.h
rename : js/src/ion/IonInstrumentation.h => js/src/jit/IonInstrumentation.h
rename : js/src/ion/IonLinker.h => js/src/jit/IonLinker.h
rename : js/src/ion/IonMacroAssembler.cpp => js/src/jit/IonMacroAssembler.cpp
rename : js/src/ion/IonMacroAssembler.h => js/src/jit/IonMacroAssembler.h
rename : js/src/ion/IonSpewer.cpp => js/src/jit/IonSpewer.cpp
rename : js/src/ion/IonSpewer.h => js/src/jit/IonSpewer.h
rename : js/src/ion/IonTypes.h => js/src/jit/IonTypes.h
rename : js/src/ion/JSONSpewer.cpp => js/src/jit/JSONSpewer.cpp
rename : js/src/ion/JSONSpewer.h => js/src/jit/JSONSpewer.h
rename : js/src/ion/LICM.cpp => js/src/jit/LICM.cpp
rename : js/src/ion/LICM.h => js/src/jit/LICM.h
rename : js/src/ion/LIR-Common.h => js/src/jit/LIR-Common.h
rename : js/src/ion/LIR.cpp => js/src/jit/LIR.cpp
rename : js/src/ion/LIR.h => js/src/jit/LIR.h
rename : js/src/ion/LOpcodes.h => js/src/jit/LOpcodes.h
rename : js/src/ion/LinearScan.cpp => js/src/jit/LinearScan.cpp
rename : js/src/ion/LinearScan.h => js/src/jit/LinearScan.h
rename : js/src/ion/LiveRangeAllocator.cpp => js/src/jit/LiveRangeAllocator.cpp
rename : js/src/ion/LiveRangeAllocator.h => js/src/jit/LiveRangeAllocator.h
rename : js/src/ion/Lowering.cpp => js/src/jit/Lowering.cpp
rename : js/src/ion/Lowering.h => js/src/jit/Lowering.h
rename : js/src/ion/MCallOptimize.cpp => js/src/jit/MCallOptimize.cpp
rename : js/src/ion/MIR.cpp => js/src/jit/MIR.cpp
rename : js/src/ion/MIR.h => js/src/jit/MIR.h
rename : js/src/ion/MIRGenerator.h => js/src/jit/MIRGenerator.h
rename : js/src/ion/MIRGraph.cpp => js/src/jit/MIRGraph.cpp
rename : js/src/ion/MIRGraph.h => js/src/jit/MIRGraph.h
rename : js/src/ion/MOpcodes.h => js/src/jit/MOpcodes.h
rename : js/src/ion/MoveEmitter.h => js/src/jit/MoveEmitter.h
rename : js/src/ion/MoveResolver.cpp => js/src/jit/MoveResolver.cpp
rename : js/src/ion/MoveResolver.h => js/src/jit/MoveResolver.h
rename : js/src/ion/ParallelFunctions.cpp => js/src/jit/ParallelFunctions.cpp
rename : js/src/ion/ParallelFunctions.h => js/src/jit/ParallelFunctions.h
rename : js/src/ion/ParallelSafetyAnalysis.cpp => js/src/jit/ParallelSafetyAnalysis.cpp
rename : js/src/ion/ParallelSafetyAnalysis.h => js/src/jit/ParallelSafetyAnalysis.h
rename : js/src/ion/PcScriptCache.h => js/src/jit/PcScriptCache.h
rename : js/src/ion/PerfSpewer.cpp => js/src/jit/PerfSpewer.cpp
rename : js/src/ion/PerfSpewer.h => js/src/jit/PerfSpewer.h
rename : js/src/ion/RangeAnalysis.cpp => js/src/jit/RangeAnalysis.cpp
rename : js/src/ion/RangeAnalysis.h => js/src/jit/RangeAnalysis.h
rename : js/src/ion/RegisterAllocator.cpp => js/src/jit/RegisterAllocator.cpp
rename : js/src/ion/RegisterAllocator.h => js/src/jit/RegisterAllocator.h
rename : js/src/ion/RegisterSets.h => js/src/jit/RegisterSets.h
rename : js/src/ion/Registers.h => js/src/jit/Registers.h
rename : js/src/ion/Safepoints.cpp => js/src/jit/Safepoints.cpp
rename : js/src/ion/Safepoints.h => js/src/jit/Safepoints.h
rename : js/src/ion/SnapshotReader.h => js/src/jit/SnapshotReader.h
rename : js/src/ion/SnapshotWriter.h => js/src/jit/SnapshotWriter.h
rename : js/src/ion/Snapshots.cpp => js/src/jit/Snapshots.cpp
rename : js/src/ion/StackSlotAllocator.h => js/src/jit/StackSlotAllocator.h
rename : js/src/ion/StupidAllocator.cpp => js/src/jit/StupidAllocator.cpp
rename : js/src/ion/StupidAllocator.h => js/src/jit/StupidAllocator.h
rename : js/src/ion/TypePolicy.cpp => js/src/jit/TypePolicy.cpp
rename : js/src/ion/TypePolicy.h => js/src/jit/TypePolicy.h
rename : js/src/ion/UnreachableCodeElimination.cpp => js/src/jit/UnreachableCodeElimination.cpp
rename : js/src/ion/UnreachableCodeElimination.h => js/src/jit/UnreachableCodeElimination.h
rename : js/src/ion/VMFunctions.cpp => js/src/jit/VMFunctions.cpp
rename : js/src/ion/VMFunctions.h => js/src/jit/VMFunctions.h
rename : js/src/ion/ValueNumbering.cpp => js/src/jit/ValueNumbering.cpp
rename : js/src/ion/ValueNumbering.h => js/src/jit/ValueNumbering.h
rename : js/src/ion/arm/Architecture-arm.cpp => js/src/jit/arm/Architecture-arm.cpp
rename : js/src/ion/arm/Architecture-arm.h => js/src/jit/arm/Architecture-arm.h
rename : js/src/ion/arm/Assembler-arm.cpp => js/src/jit/arm/Assembler-arm.cpp
rename : js/src/ion/arm/Assembler-arm.h => js/src/jit/arm/Assembler-arm.h
rename : js/src/ion/arm/Bailouts-arm.cpp => js/src/jit/arm/Bailouts-arm.cpp
rename : js/src/ion/arm/BaselineCompiler-arm.cpp => js/src/jit/arm/BaselineCompiler-arm.cpp
rename : js/src/ion/arm/BaselineCompiler-arm.h => js/src/jit/arm/BaselineCompiler-arm.h
rename : js/src/ion/arm/BaselineHelpers-arm.h => js/src/jit/arm/BaselineHelpers-arm.h
rename : js/src/ion/arm/BaselineIC-arm.cpp => js/src/jit/arm/BaselineIC-arm.cpp
rename : js/src/ion/arm/BaselineRegisters-arm.h => js/src/jit/arm/BaselineRegisters-arm.h
rename : js/src/ion/arm/CodeGenerator-arm.cpp => js/src/jit/arm/CodeGenerator-arm.cpp
rename : js/src/ion/arm/CodeGenerator-arm.h => js/src/jit/arm/CodeGenerator-arm.h
rename : js/src/ion/arm/IonFrames-arm.cpp => js/src/jit/arm/IonFrames-arm.cpp
rename : js/src/ion/arm/IonFrames-arm.h => js/src/jit/arm/IonFrames-arm.h
rename : js/src/ion/arm/LIR-arm.h => js/src/jit/arm/LIR-arm.h
rename : js/src/ion/arm/LOpcodes-arm.h => js/src/jit/arm/LOpcodes-arm.h
rename : js/src/ion/arm/Lowering-arm.cpp => js/src/jit/arm/Lowering-arm.cpp
rename : js/src/ion/arm/Lowering-arm.h => js/src/jit/arm/Lowering-arm.h
rename : js/src/ion/arm/MacroAssembler-arm.cpp => js/src/jit/arm/MacroAssembler-arm.cpp
rename : js/src/ion/arm/MacroAssembler-arm.h => js/src/jit/arm/MacroAssembler-arm.h
rename : js/src/ion/arm/MoveEmitter-arm.cpp => js/src/jit/arm/MoveEmitter-arm.cpp
rename : js/src/ion/arm/MoveEmitter-arm.h => js/src/jit/arm/MoveEmitter-arm.h
rename : js/src/ion/arm/Trampoline-arm.cpp => js/src/jit/arm/Trampoline-arm.cpp
rename : js/src/ion/shared/Assembler-shared.h => js/src/jit/shared/Assembler-shared.h
rename : js/src/ion/shared/Assembler-x86-shared.cpp => js/src/jit/shared/Assembler-x86-shared.cpp
rename : js/src/ion/shared/Assembler-x86-shared.h => js/src/jit/shared/Assembler-x86-shared.h
rename : js/src/ion/shared/BaselineCompiler-shared.cpp => js/src/jit/shared/BaselineCompiler-shared.cpp
rename : js/src/ion/shared/BaselineCompiler-shared.h => js/src/jit/shared/BaselineCompiler-shared.h
rename : js/src/ion/shared/BaselineCompiler-x86-shared.cpp => js/src/jit/shared/BaselineCompiler-x86-shared.cpp
rename : js/src/ion/shared/BaselineCompiler-x86-shared.h => js/src/jit/shared/BaselineCompiler-x86-shared.h
rename : js/src/ion/shared/BaselineIC-x86-shared.cpp => js/src/jit/shared/BaselineIC-x86-shared.cpp
rename : js/src/ion/shared/CodeGenerator-shared-inl.h => js/src/jit/shared/CodeGenerator-shared-inl.h
rename : js/src/ion/shared/CodeGenerator-shared.cpp => js/src/jit/shared/CodeGenerator-shared.cpp
rename : js/src/ion/shared/CodeGenerator-shared.h => js/src/jit/shared/CodeGenerator-shared.h
rename : js/src/ion/shared/CodeGenerator-x86-shared.cpp => js/src/jit/shared/CodeGenerator-x86-shared.cpp
rename : js/src/ion/shared/CodeGenerator-x86-shared.h => js/src/jit/shared/CodeGenerator-x86-shared.h
rename : js/src/ion/shared/IonAssemblerBuffer.h => js/src/jit/shared/IonAssemblerBuffer.h
rename : js/src/ion/shared/IonAssemblerBufferWithConstantPools.h => js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
rename : js/src/ion/shared/IonFrames-shared.h => js/src/jit/shared/IonFrames-shared.h
rename : js/src/ion/shared/IonFrames-x86-shared.cpp => js/src/jit/shared/IonFrames-x86-shared.cpp
rename : js/src/ion/shared/IonFrames-x86-shared.h => js/src/jit/shared/IonFrames-x86-shared.h
rename : js/src/ion/shared/LIR-x86-shared.h => js/src/jit/shared/LIR-x86-shared.h
rename : js/src/ion/shared/Lowering-shared-inl.h => js/src/jit/shared/Lowering-shared-inl.h
rename : js/src/ion/shared/Lowering-shared.cpp => js/src/jit/shared/Lowering-shared.cpp
rename : js/src/ion/shared/Lowering-shared.h => js/src/jit/shared/Lowering-shared.h
rename : js/src/ion/shared/Lowering-x86-shared.cpp => js/src/jit/shared/Lowering-x86-shared.cpp
rename : js/src/ion/shared/Lowering-x86-shared.h => js/src/jit/shared/Lowering-x86-shared.h
rename : js/src/ion/shared/MacroAssembler-x86-shared.h => js/src/jit/shared/MacroAssembler-x86-shared.h
rename : js/src/ion/shared/MoveEmitter-x86-shared.cpp => js/src/jit/shared/MoveEmitter-x86-shared.cpp
rename : js/src/ion/shared/MoveEmitter-x86-shared.h => js/src/jit/shared/MoveEmitter-x86-shared.h
rename : js/src/ion/x64/Architecture-x64.h => js/src/jit/x64/Architecture-x64.h
rename : js/src/ion/x64/Assembler-x64.cpp => js/src/jit/x64/Assembler-x64.cpp
rename : js/src/ion/x64/Assembler-x64.h => js/src/jit/x64/Assembler-x64.h
rename : js/src/ion/x64/Bailouts-x64.cpp => js/src/jit/x64/Bailouts-x64.cpp
rename : js/src/ion/x64/BaselineCompiler-x64.cpp => js/src/jit/x64/BaselineCompiler-x64.cpp
rename : js/src/ion/x64/BaselineCompiler-x64.h => js/src/jit/x64/BaselineCompiler-x64.h
rename : js/src/ion/x64/BaselineHelpers-x64.h => js/src/jit/x64/BaselineHelpers-x64.h
rename : js/src/ion/x64/BaselineIC-x64.cpp => js/src/jit/x64/BaselineIC-x64.cpp
rename : js/src/ion/x64/BaselineRegisters-x64.h => js/src/jit/x64/BaselineRegisters-x64.h
rename : js/src/ion/x64/CodeGenerator-x64.cpp => js/src/jit/x64/CodeGenerator-x64.cpp
rename : js/src/ion/x64/CodeGenerator-x64.h => js/src/jit/x64/CodeGenerator-x64.h
rename : js/src/ion/x64/LIR-x64.h => js/src/jit/x64/LIR-x64.h
rename : js/src/ion/x64/LOpcodes-x64.h => js/src/jit/x64/LOpcodes-x64.h
rename : js/src/ion/x64/Lowering-x64.cpp => js/src/jit/x64/Lowering-x64.cpp
rename : js/src/ion/x64/Lowering-x64.h => js/src/jit/x64/Lowering-x64.h
rename : js/src/ion/x64/MacroAssembler-x64.cpp => js/src/jit/x64/MacroAssembler-x64.cpp
rename : js/src/ion/x64/MacroAssembler-x64.h => js/src/jit/x64/MacroAssembler-x64.h
rename : js/src/ion/x64/Trampoline-x64.cpp => js/src/jit/x64/Trampoline-x64.cpp
rename : js/src/ion/x86/Architecture-x86.h => js/src/jit/x86/Architecture-x86.h
rename : js/src/ion/x86/Assembler-x86.cpp => js/src/jit/x86/Assembler-x86.cpp
rename : js/src/ion/x86/Assembler-x86.h => js/src/jit/x86/Assembler-x86.h
rename : js/src/ion/x86/Bailouts-x86.cpp => js/src/jit/x86/Bailouts-x86.cpp
rename : js/src/ion/x86/BaselineCompiler-x86.cpp => js/src/jit/x86/BaselineCompiler-x86.cpp
rename : js/src/ion/x86/BaselineCompiler-x86.h => js/src/jit/x86/BaselineCompiler-x86.h
rename : js/src/ion/x86/BaselineHelpers-x86.h => js/src/jit/x86/BaselineHelpers-x86.h
rename : js/src/ion/x86/BaselineIC-x86.cpp => js/src/jit/x86/BaselineIC-x86.cpp
rename : js/src/ion/x86/BaselineRegisters-x86.h => js/src/jit/x86/BaselineRegisters-x86.h
rename : js/src/ion/x86/CodeGenerator-x86.cpp => js/src/jit/x86/CodeGenerator-x86.cpp
rename : js/src/ion/x86/CodeGenerator-x86.h => js/src/jit/x86/CodeGenerator-x86.h
rename : js/src/ion/x86/LIR-x86.h => js/src/jit/x86/LIR-x86.h
rename : js/src/ion/x86/LOpcodes-x86.h => js/src/jit/x86/LOpcodes-x86.h
rename : js/src/ion/x86/Lowering-x86.cpp => js/src/jit/x86/Lowering-x86.cpp
rename : js/src/ion/x86/Lowering-x86.h => js/src/jit/x86/Lowering-x86.h
rename : js/src/ion/x86/MacroAssembler-x86.cpp => js/src/jit/x86/MacroAssembler-x86.cpp
rename : js/src/ion/x86/MacroAssembler-x86.h => js/src/jit/x86/MacroAssembler-x86.h
rename : js/src/ion/x86/Trampoline-x86.cpp => js/src/jit/x86/Trampoline-x86.cpp
2013-08-08 19:37:11 +02:00

397 lines
14 KiB
Python

# vim: set ts=8 sts=4 et sw=4 tw=99:
# 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/.
#----------------------------------------------------------------------------
# This script checks various aspects of SpiderMonkey code style. The current checks are as
# follows.
#
# We check the following things in headers.
#
# - No cyclic dependencies.
#
# - No normal header should #include a inlines.h/-inl.h file.
#
# - #ifndef wrappers should have the right form. (XXX: not yet implemented)
# - Every header file should have one.
# - It should be in the vanilla form and have no tokens before/after it so
# that GCC and clang can avoid multiple-inclusion.
# - The guard name used should be appropriate for the filename.
#
# We check the following things in all files.
#
# - #includes should have full paths, e.g. "jit/Ion.h", not "Ion.h".
#
# - #includes should use the appropriate form for system headers (<...>) and
# local headers ("...").
#
# - #includes should be ordered correctly. (XXX: not yet implemented; see bug
# 888088)
# - Each one should be in the correct section.
# - Alphabetical order should be used within sections.
# - Sections should be in the right order.
#----------------------------------------------------------------------------
from __future__ import print_function
import difflib
import os
import re
import subprocess
import sys
import traceback
# We don't bother checking files in these directories, because they're (a) auxiliary or (b)
# imported code that doesn't follow our coding style.
ignored_js_src_dirs = [
'js/src/config/', # auxiliary stuff
'js/src/ctypes/libffi/', # imported code
'js/src/devtools/', # auxiliary stuff
'js/src/editline/', # imported code
'js/src/gdb/', # auxiliary stuff
'js/src/vtune/' # imported code
]
# We ignore #includes of these files, because they don't follow the usual rules.
included_inclnames_to_ignore = set([
'ffi.h', # generated in ctypes/libffi/
'devtools/sharkctl.h', # we ignore devtools/ in general
'devtools/Instruments.h', # we ignore devtools/ in general
'double-conversion.h', # strange MFBT case
'javascript-trace.h', # generated in $OBJDIR if HAVE_DTRACE is defined
'jsautokw.h', # generated in $OBJDIR
'jsautooplen.h', # generated in $OBJDIR
'jscustomallocator.h', # provided by embedders; allowed to be missing
'js-config.h', # generated in $OBJDIR
'pratom.h', # NSPR
'prcvar.h', # NSPR
'prinit.h', # NSPR
'prlink.h', # NSPR
'prlock.h', # NSPR
'prprf.h', # NSPR
'prthread.h', # NSPR
'prtypes.h', # NSPR
'selfhosted.out.h', # generated in $OBJDIR
'unicode/locid.h', # ICU
'unicode/numsys.h', # ICU
'unicode/ucal.h', # ICU
'unicode/uclean.h', # ICU
'unicode/ucol.h', # ICU
'unicode/udat.h', # ICU
'unicode/udatpg.h', # ICU
'unicode/uenum.h', # ICU
'unicode/unum.h', # ICU
'unicode/ustring.h', # ICU
'unicode/utypes.h', # ICU
'vtune/VTuneWrapper.h' # VTune
])
# The files in tests/style/ contain code that fails this checking in various
# ways. Here is the output we expect. If the actual output differs from
# this, one of the following must have happened.
# - New SpiderMonkey code violates one of the checked rules.
# - The tests/style/ files have changed without expected_output being changed
# accordingly.
# - This script has been broken somehow.
#
expected_output = '''\
js/src/tests/style/BadIncludes2.h:1: error:
vanilla header includes an inline-header file "tests/style/BadIncludes2-inl.h"
js/src/tests/style/BadIncludes.h:1: error:
the file includes itself
js/src/tests/style/BadIncludes.h:3: error:
"BadIncludes2.h" is included using the wrong path;
did you forget a prefix, or is the file not yet committed?
js/src/tests/style/BadIncludes.h:4: error:
<tests/style/BadIncludes2.h> should be included using
the #include "..." form
js/src/tests/style/BadIncludes.h:5: error:
"stdio.h" is included using the wrong path;
did you forget a prefix, or is the file not yet committed?
(multiple files): error:
header files form one or more cycles
tests/style/HeaderCycleA1.h
-> tests/style/HeaderCycleA2.h
-> tests/style/HeaderCycleA3.h
-> tests/style/HeaderCycleA1.h
tests/style/HeaderCycleB1-inl.h
-> tests/style/HeaderCycleB2-inl.h
-> tests/style/HeaderCycleB3-inl.h
-> tests/style/HeaderCycleB4-inl.h
-> tests/style/HeaderCycleB1-inl.h
-> tests/style/jsheadercycleB5inlines.h
-> tests/style/HeaderCycleB1-inl.h
-> tests/style/HeaderCycleB4-inl.h
'''.splitlines(True)
actual_output = []
def out(*lines):
for line in lines:
actual_output.append(line + '\n')
def error(filename, linenum, *lines):
location = filename
if linenum != None:
location += ":" + str(linenum)
out(location + ': error:')
for line in (lines):
out(' ' + line)
out('')
class FileKind(object):
C = 1
CPP = 2
INL_H = 3
H = 4
TBL = 5
MSG = 6
@staticmethod
def get(filename):
if filename.endswith('.c'):
return FileKind.C
if filename.endswith('.cpp'):
return FileKind.CPP
if filename.endswith(('inlines.h', '-inl.h')):
return FileKind.INL_H
if filename.endswith('.h'):
return FileKind.H
if filename.endswith('.tbl'):
return FileKind.TBL
if filename.endswith('.msg'):
return FileKind.MSG
error(filename, None, 'unknown file kind')
def get_all_filenames():
"""Get a list of all the files in the (Mercurial or Git) repository."""
cmds = [['hg', 'manifest', '-q'], ['git', 'ls-files']]
for cmd in cmds:
try:
all_filenames = subprocess.check_output(cmd, universal_newlines=True,
stderr=subprocess.PIPE).split('\n')
return all_filenames
except:
continue
else:
raise Exception('failed to run any of the repo manifest commands', cmds)
def check_style():
# We deal with two kinds of name.
# - A "filename" is a full path to a file from the repository root.
# - An "inclname" is how a file is referred to in a #include statement.
#
# Examples (filename -> inclname)
# - "mfbt/Attributes.h" -> "mozilla/Attributes.h"
# - "js/public/Vector.h" -> "js/Vector.h"
# - "js/src/vm/String.h" -> "vm/String.h"
mfbt_inclnames = set() # type: set(inclname)
js_names = dict() # type: dict(filename, inclname)
# Select the appropriate files.
for filename in get_all_filenames():
if filename.startswith('mfbt/') and filename.endswith('.h'):
inclname = 'mozilla/' + filename[len('mfbt/'):]
mfbt_inclnames.add(inclname)
if filename.startswith('js/public/') and filename.endswith('.h'):
inclname = 'js/' + filename[len('js/public/'):]
js_names[filename] = inclname
if filename.startswith('js/src/') and \
not filename.startswith(tuple(ignored_js_src_dirs)) and \
filename.endswith(('.c', '.cpp', '.h', '.tbl', '.msg')):
inclname = filename[len('js/src/'):]
js_names[filename] = inclname
all_inclnames = mfbt_inclnames | set(js_names.values())
edges = dict() # type: dict(inclname, set(inclname))
# We don't care what's inside the MFBT files, but because they are
# #included from JS files we have to add them to the inclusion graph.
for inclname in mfbt_inclnames:
edges[inclname] = set()
# Process all the JS files.
for filename in js_names.keys():
inclname = js_names[filename]
file_kind = FileKind.get(filename)
if file_kind == FileKind.C or file_kind == FileKind.CPP or \
file_kind == FileKind.H or file_kind == FileKind.INL_H:
included_h_inclnames = set() # type: set(inclname)
# This script is run in js/src/, so prepend '../../' to get to the root of the Mozilla
# source tree.
with open(os.path.join('../..', filename)) as f:
do_file(filename, inclname, file_kind, f, all_inclnames, included_h_inclnames)
edges[inclname] = included_h_inclnames
find_cycles(all_inclnames, edges)
# Compare expected and actual output.
difflines = difflib.unified_diff(expected_output, actual_output,
fromfile='check_spider_monkey_style.py expected output',
tofile='check_spider_monkey_style.py actual output')
ok = True
for diffline in difflines:
ok = False
print(diffline, end='')
return ok
def do_file(filename, inclname, file_kind, f, all_inclnames, included_h_inclnames):
for linenum, line in enumerate(f, start=1):
# Look for a |#include "..."| line.
m = re.match(r'\s*#\s*include\s+"([^"]*)"', line)
if m is not None:
included_inclname = m.group(1)
if included_inclname not in included_inclnames_to_ignore:
included_kind = FileKind.get(included_inclname)
# Check the #include path has the correct form.
if included_inclname not in all_inclnames:
error(filename, linenum,
'"' + included_inclname + '" is included ' + 'using the wrong path;',
'did you forget a prefix, or is the file not yet committed?')
# Record inclusions of .h files for cycle detection later.
# (Exclude .tbl and .msg files.)
elif included_kind == FileKind.H or included_kind == FileKind.INL_H:
included_h_inclnames.add(included_inclname)
# Check a H file doesn't #include an INL_H file.
if file_kind == FileKind.H and included_kind == FileKind.INL_H:
error(filename, linenum,
'vanilla header includes an inline-header file "' + included_inclname + '"')
# Check a file doesn't #include itself. (We do this here because the
# cycle detection below doesn't detect this case.)
if inclname == included_inclname:
error(filename, linenum, 'the file includes itself')
# Look for a |#include <...>| line.
m = re.match(r'\s*#\s*include\s+<([^>]*)>', line)
if m is not None:
included_inclname = m.group(1)
# Check it is not a known local file (in which case it's
# probably a system header).
if included_inclname in included_inclnames_to_ignore or \
included_inclname in all_inclnames:
error(filename, linenum,
'<' + included_inclname + '> should be included using',
'the #include "..." form')
def find_cycles(all_inclnames, edges):
"""Find and draw any cycles."""
SCCs = tarjan(all_inclnames, edges)
# The various sorted() calls below ensure the output is deterministic.
def draw_SCC(c):
cset = set(c)
drawn = set()
def draw(v, indent):
out(' ' * indent + ('-> ' if indent else ' ') + v)
if v in drawn:
return
drawn.add(v)
for succ in sorted(edges[v]):
if succ in cset:
draw(succ, indent + 1)
draw(sorted(c)[0], 0)
out('')
have_drawn_an_SCC = False
for scc in sorted(SCCs):
if len(scc) != 1:
if not have_drawn_an_SCC:
error('(multiple files)', None, 'header files form one or more cycles')
have_drawn_an_SCC = True
draw_SCC(scc)
# Tarjan's algorithm for finding the strongly connected components (SCCs) of a graph.
# https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
def tarjan(V, E):
vertex_index = {}
vertex_lowlink = {}
index = 0
S = []
all_SCCs = []
def strongconnect(v, index):
# Set the depth index for v to the smallest unused index
vertex_index[v] = index
vertex_lowlink[v] = index
index += 1
S.append(v)
# Consider successors of v
for w in E[v]:
if w not in vertex_index:
# Successor w has not yet been visited; recurse on it
index = strongconnect(w, index)
vertex_lowlink[v] = min(vertex_lowlink[v], vertex_lowlink[w])
elif w in S:
# Successor w is in stack S and hence in the current SCC
vertex_lowlink[v] = min(vertex_lowlink[v], vertex_index[w])
# If v is a root node, pop the stack and generate an SCC
if vertex_lowlink[v] == vertex_index[v]:
i = S.index(v)
scc = S[i:]
del S[i:]
all_SCCs.append(scc)
return index
for v in V:
if v not in vertex_index:
index = strongconnect(v, index)
return all_SCCs
def main():
ok = check_style()
if ok:
print('TEST-PASS | check_spidermonkey_style.py | ok')
else:
print('TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | actual output does not match expected output; diff is above')
sys.exit(0 if ok else 1)
if __name__ == "__main__":
main()