run_clang_tidy.py 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python3
  2. """Runs clang-tidy over all Carbon files.
  3. """
  4. __copyright__ = """
  5. Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  6. Exceptions. See /LICENSE for license information.
  7. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  8. """
  9. import os
  10. import subprocess
  11. import sys
  12. from pathlib import Path
  13. def main() -> None:
  14. # Set the repo root as the working directory.
  15. os.chdir(Path(__file__).parent.parent)
  16. # Ensure create_compdb has been run.
  17. subprocess.check_call(["./scripts/create_compdb.py"])
  18. args = sys.argv[1:]
  19. if not args or args[0] == "--fix":
  20. args.append("^(?!.*/(bazel-|third_party)).*$")
  21. # Run clang-tidy from clang-tools-extra.
  22. exit(
  23. subprocess.call(
  24. [
  25. "./bazel-execroot/external/llvm-project/clang-tools-extra/"
  26. "clang-tidy/tool/run-clang-tidy.py",
  27. ]
  28. + args
  29. )
  30. )
  31. if __name__ == "__main__":
  32. main()