From b8e1a6833ccca0ea59f2b0894963fe7b36adebc1 Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov <5928869+goodov@users.noreply.github.com> Date: Thu, 23 Feb 2023 00:08:41 +0700 Subject: [PATCH] Introduce brave/.clangd config. (#17299) --- .clangd | 18 ++++++++++++++++++ .gitattributes | 9 ++++----- .../tools/clang/pylib/clang/compile_db.py | 19 ++++++++----------- 3 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 00000000000..85cc922a5aa --- /dev/null +++ b/.clangd @@ -0,0 +1,18 @@ +# Copyright (c) 2023 The Brave Authors. All rights reserved. +# 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 https://mozilla.org/MPL/2.0/. + +# Enable strict unused includes check. +If: + PathMatch: [.*\.h, .*\.cc, .*\.mm] +Diagnostics: + UnusedIncludes: Strict +--- + +# Disable unused const variables warning in headers. Clangd may build .h files +# directly, which triggers this warning on clang-cl (only on Windows). +If: + PathMatch: .*\.h +CompileFlags: + Add: -Wnounused-const-variable diff --git a/.gitattributes b/.gitattributes index 6c832c69993..e717866d094 100644 --- a/.gitattributes +++ b/.gitattributes @@ -35,12 +35,11 @@ *.xslt text eol=lf *.xtb text eol=lf -.clang-format text eol=lf -.eslintrc.js text eol=lf +.clang* text eol=lf .git-blame-ignore-revs text eol=lf -.gitattributes text eol=lf -.gitignore text eol=lf -.vpython text eol=lf +.gitattributes text eol=lf +.gitignore text eol=lf +.vpython* text eol=lf DEPS text eol=lf LICENSE text eol=lf diff --git a/chromium_src/tools/clang/pylib/clang/compile_db.py b/chromium_src/tools/clang/pylib/clang/compile_db.py index 29c77461776..c7a437d7c10 100644 --- a/chromium_src/tools/clang/pylib/clang/compile_db.py +++ b/chromium_src/tools/clang/pylib/clang/compile_db.py @@ -8,7 +8,7 @@ import re import override_utils # Remove redirect_cc from the command line. -GOMACC_PATTERN_TO_REPLACE = ('gomacc(\.exe)', '(gomacc|redirect_cc)(\.exe)') +GOMACC_PATTERN_TO_REPLACE = (r'gomacc(\.exe)', r'(gomacc|redirect_cc)(\.exe)') # pylint: disable=used-before-assignment assert GOMACC_PATTERN_TO_REPLACE[0] in _GOMA_CMD_LINE_RE.pattern @@ -19,14 +19,11 @@ _GOMA_CMD_LINE_RE = re.compile( @override_utils.override_function(globals()) def _FilterFlags(original_function, command, additional_filtered_flags): flags = original_function(command, additional_filtered_flags) - if additional_filtered_flags: - # Use --filter_arg to pass brave-specific args to apply here. - flags_to_restore = { - 'brave-keep-bitint256': - ' -Xclang -fexperimental-max-bitint-width=256', - } - for external_flag, flag_to_restore in flags_to_restore.items(): - if external_flag in additional_filtered_flags: - if flag_to_restore in command and flag_to_restore not in flags: - flags += flag_to_restore + flags_to_restore = [ + # Clangd 15+ is required, VSCode extension includes it. + ' -Xclang -fexperimental-max-bitint-width=256', + ] + for flag_to_restore in flags_to_restore: + if flag_to_restore in command and flag_to_restore not in flags: + flags += flag_to_restore return flags