diff options
author | Hans Wennborg <hans@chromium.org> | 2019-10-09 15:22:38 +0200 |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2020-01-27 16:04:17 +0100 |
commit | 739b410f1ff51d507830774320c2db3a80d8610d (patch) | |
tree | 822254e9d231cea1f63effc82f633dcf67dcd0d1 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 9965b12fd1bcb78396fbea2c28d80068e43b31a3 (diff) | |
download | llvm-739b410f1ff51d507830774320c2db3a80d8610d.zip llvm-739b410f1ff51d507830774320c2db3a80d8610d.tar.gz llvm-739b410f1ff51d507830774320c2db3a80d8610d.tar.bz2 |
Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit
See
https://docs.google.com/document/d/1xMkTZMKx9llnMPgso0jrx3ankI4cv60xeZ0y4ksf4wc/preview
for background discussion.
This adds a warning, flags and pragmas to limit the number of
pre-processor tokens either at a certain point in a translation unit, or
overall.
The idea is that this would allow projects to limit the size of certain
widely included headers, or for translation units overall, as a way to
insert backstops for header bloat and prevent compile-time regressions.
Differential revision: https://reviews.llvm.org/D72703
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 847b613..eb1c50f 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3292,6 +3292,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers); Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj); + + Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens, 0, Diags); } static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { |