[clang] 87b235d - Turn -Wmax-tokens off by default

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon May 18 04:22:03 PDT 2020


Author: Hans Wennborg
Date: 2020-05-18T13:21:46+02:00
New Revision: 87b235db63a3d8d5b82d60ef6202b92b94a7d9d2

URL: https://github.com/llvm/llvm-project/commit/87b235db63a3d8d5b82d60ef6202b92b94a7d9d2
DIFF: https://github.com/llvm/llvm-project/commit/87b235db63a3d8d5b82d60ef6202b92b94a7d9d2.diff

LOG: Turn -Wmax-tokens off by default

On the one hand, one might interpret the use of the max-token pragmas or
-fmax-tokens flag as an opt-in to the warning. However, in Chromium
we've found it useful to only opt in selected build configurations, even
though we have the pragmas in the code. For that reason, we think it
makes sense to turn it off by default.

Differential revision: https://reviews.llvm.org/D80014

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticGroups.td
    clang/include/clang/Basic/DiagnosticParseKinds.td
    clang/test/Parser/max-tokens.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index b6a252ac01a9..c9104da66f1f 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1202,5 +1202,8 @@ the token limit, which can be set in three ways:
 These limits can be helpful in limiting code growth through included files.
 
 Setting a token limit of zero means no limit.
+
+Note that the warning is disabled by default, so -Wmax-tokens must be used
+in addition with the pragmas or -fmax-tokens flag to get any warnings.
 }];
 }

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index f32ff65948b0..5d57cfd6e71d 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1428,11 +1428,11 @@ def err_placeholder_expected_auto_or_decltype_auto : Error<
 
 def warn_max_tokens : Warning<
   "the number of preprocessor source tokens (%0) exceeds this token limit (%1)">,
-  InGroup<MaxTokens>;
+  InGroup<MaxTokens>, DefaultIgnore;
 
 def warn_max_tokens_total : Warning<
   "the total number of preprocessor source tokens (%0) exceeds the token limit (%1)">,
-  InGroup<MaxTokens>;
+  InGroup<MaxTokens>, DefaultIgnore;
 
 def note_max_tokens_total_override : Note<"total token limit set here">;
 

diff  --git a/clang/test/Parser/max-tokens.cpp b/clang/test/Parser/max-tokens.cpp
index 5be892773fe4..f98332d21afd 100644
--- a/clang/test/Parser/max-tokens.cpp
+++ b/clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS          -fmax-tokens=2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens=9
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens -DMAX_TOKENS          -fmax-tokens=2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens -DMAX_TOKENS_OVERRIDE -fmax-tokens=9
 
 int x, y, z;
 


        


More information about the cfe-commits mailing list