hans created this revision.
hans added a reviewer: thakis.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80014

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


Index: clang/test/Parser/max-tokens.cpp
===================================================================
--- clang/test/Parser/max-tokens.cpp
+++ 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;
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1428,11 +1428,11 @@
 
 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">;
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1202,5 +1202,8 @@
 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.
 }];
 }


Index: clang/test/Parser/max-tokens.cpp
===================================================================
--- clang/test/Parser/max-tokens.cpp
+++ 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;
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1428,11 +1428,11 @@
 
 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">;
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1202,5 +1202,8 @@
 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.
 }];
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D80014: Turn -Wmax-t... Hans Wennborg via Phabricator via cfe-commits

Reply via email to