mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
This patches bazel_clang_tidy handling of headers. I found an equivalent change at https://github.com/erenon/bazel_clang_tidy/pull/13, but that was [already rejected](https://github.com/erenon/bazel_clang_tidy/pull/13#issuecomment-1047007424). Per the criticism, this will result in redundant processing of headers. The project instead uses `HeaderFilterRegex: ".*"`, but that results in two problems: 1. When running with `-k`, errors are repeated when a header is included more than once, which is common. 2. clang-tidy including errors from headers that are included from other modules (e.g., abseil-cpp); filtering correctly is difficult. Given the trade-offs and options (including forking), I thought patching was preferable so long as it remains narrow.
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "common/init_llvm.h"
|
|
|
|
#include "llvm/Support/TargetSelect.h"
|
|
|
|
namespace Carbon {
|
|
|
|
InitLLVM::InitLLVM(int& argc, char**& argv)
|
|
: init_llvm_(argc, argv),
|
|
// LLVM assumes that argc and argv won't change, and registers them with
|
|
// an `llvm::PrettyStackTraceProgram` that will crash if an argv element
|
|
// gets nulled out, which for example `testing::InitGoogleTest` does. So
|
|
// make a copy of the argv that LLVM produces in order to support
|
|
// mutation.
|
|
args_(argv, argv + argc) {
|
|
// Return our mutable copy of argv for the program to use.
|
|
argc = args_.size();
|
|
argv = args_.data();
|
|
|
|
// `argv[argc]` is expected to be a null pointer.
|
|
args_.push_back(nullptr);
|
|
|
|
llvm::setBugReportMsg(
|
|
"Please report issues to "
|
|
"https://github.com/carbon-language/carbon-lang/issues and include the "
|
|
"crash backtrace.\n");
|
|
|
|
// Initialize LLVM targets if //common:all_llvm_targets was linked in.
|
|
if (InitializeTargets) {
|
|
InitializeTargets();
|
|
}
|
|
}
|
|
|
|
InitLLVM::InitializeTargetsFn* InitLLVM::InitializeTargets = nullptr;
|
|
|
|
} // namespace Carbon
|