Skip to content

Commit c971ccf

Browse files
authored
Merge branch 'main' into set-fast-flags-for-evlrecipe
2 parents 6d7d92f + ac1d560 commit c971ccf

File tree

552 files changed

+22888
-4579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

552 files changed

+22888
-4579
lines changed

clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
#include "../GlobList.h"
2121
#include "clang/Tooling/CommonOptionsParser.h"
2222
#include "llvm/ADT/StringSet.h"
23+
#include "llvm/Support/CommandLine.h"
2324
#include "llvm/Support/InitLLVM.h"
2425
#include "llvm/Support/PluginLoader.h"
2526
#include "llvm/Support/Process.h"
2627
#include "llvm/Support/Signals.h"
2728
#include "llvm/Support/TargetSelect.h"
2829
#include "llvm/Support/WithColor.h"
30+
#include "llvm/TargetParser/Host.h"
2931
#include <optional>
3032

3133
using namespace clang::tooling;
@@ -36,6 +38,11 @@ static cl::desc desc(StringRef description) { return {description.ltrim()}; }
3638
static cl::OptionCategory ClangTidyCategory("clang-tidy options");
3739

3840
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
41+
static cl::extrahelp ClangTidyParameterFileHelp(R"(
42+
Parameters files:
43+
A large number of options or source files can be passed as parameter files
44+
by use '@parameter-file' in the command line.
45+
)");
3946
static cl::extrahelp ClangTidyHelp(R"(
4047
Configuration files:
4148
clang-tidy attempts to read configuration for each source file from a
@@ -571,6 +578,21 @@ static llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> createBaseFS() {
571578

572579
int clangTidyMain(int argc, const char **argv) {
573580
llvm::InitLLVM X(argc, argv);
581+
SmallVector<const char *> Args{argv, argv + argc};
582+
583+
// expand parameters file to argc and argv.
584+
llvm::BumpPtrAllocator Alloc;
585+
llvm::cl::TokenizerCallback Tokenizer =
586+
llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
587+
? llvm::cl::TokenizeWindowsCommandLine
588+
: llvm::cl::TokenizeGNUCommandLine;
589+
llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
590+
if (llvm::Error Err = ECtx.expandResponseFiles(Args)) {
591+
llvm::WithColor::error() << llvm::toString(std::move(Err)) << "\n";
592+
return 1;
593+
}
594+
argc = static_cast<int>(Args.size());
595+
argv = Args.data();
574596

575597
// Enable help for -load option, if plugins are enabled.
576598
if (cl::Option *LoadOpt = cl::getRegisteredOptions().lookup("load"))

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ Improvements to clang-tidy
115115
- Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
116116
happening on certain platforms when interrupting the script.
117117

118+
- Improved :program:`clang-tidy` by accepting parameters file in command line.
119+
118120
- Removed :program:`clang-tidy`'s global options for most of checks. All options
119121
are changed to local options except `IncludeStyle`, `StrictMode` and
120122
`IgnoreMacros`.

clang-tools-extra/docs/clang-tidy/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ compilation options on the command line after ``--``:
3333
3434
$ clang-tidy test.cpp -- -Imy_project/include -DMY_DEFINES ...
3535
36+
If there are too many options or source files to specify on the command line,
37+
you can store them in a parameter file, and use :program:`clang-tidy` with that
38+
parameters file:
39+
40+
.. code-block:: console
41+
42+
$ clang-tidy @parameters_file
43+
3644
:program:`clang-tidy` has its own checks and can also run Clang Static Analyzer
3745
checks. Each check has a name and the checks to run can be chosen using the
3846
``-checks=`` option, which specifies a comma-separated list of positive and
@@ -264,6 +272,9 @@ An overview of all the command-line options:
264272
automatically removed, but the rest of a relative path must be a
265273
suffix of a path in the compile command database.
266274
275+
Parameters files:
276+
A large number of options or source files can be passed as parameter files
277+
by use '@parameter-file' in the command line.
267278
268279
Configuration files:
269280
clang-tidy attempts to read configuration for each source file from a

0 commit comments

Comments
 (0)