[clang] b2c9b63 - [Diagnostics] Move -Wstring-concatenation to -Wextra
Dávid Bolvanský via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 10 14:36:47 PDT 2020
Author: Dávid Bolvanský
Date: 2020-08-10T23:36:33+02:00
New Revision: b2c9b631bb48087c988d798adc5465499b155a9a
URL: https://github.com/llvm/llvm-project/commit/b2c9b631bb48087c988d798adc5465499b155a9a
DIFF: https://github.com/llvm/llvm-project/commit/b2c9b631bb48087c988d798adc5465499b155a9a.diff
LOG: [Diagnostics] Move -Wstring-concatenation to -Wextra
Added:
Modified:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/string-concat.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 5ddd37e9972a..2b13f9eca12d 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -547,6 +547,7 @@ def StaticLocalInInline : DiagGroup<"static-local-in-inline">;
def GNUStaticFloatInit : DiagGroup<"gnu-static-float-init">;
def StaticFloatInit : DiagGroup<"static-float-init", [GNUStaticFloatInit]>;
def GNUStatementExpression : DiagGroup<"gnu-statement-expression">;
+def StringConcatation : DiagGroup<"string-concatenation">;
def StringCompare : DiagGroup<"string-compare">;
def StringPlusInt : DiagGroup<"string-plus-int">;
def StringPlusChar : DiagGroup<"string-plus-char">;
@@ -880,7 +881,8 @@ def Extra : DiagGroup<"extra", [
SignCompare,
UnusedParameter,
NullPointerArithmetic,
- EmptyInitStatement
+ EmptyInitStatement,
+ StringConcatation
]>;
def Most : DiagGroup<"most", [
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d0bddd80b8fe..f2e939da3050 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3005,7 +3005,7 @@ def warn_objc_string_literal_comparison : Warning<
def warn_concatenated_literal_array_init : Warning<
"suspicious concatenation of string literals in an array initialization; "
"did you mean to separate the elements with a comma?">,
- InGroup<DiagGroup<"string-concatenation">>;
+ InGroup<StringConcatation>, DefaultIgnore;
def warn_concatenated_nsarray_literal : Warning<
"concatenated NSString literal for an NSArray expression - "
"possibly missing a comma">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8f38238401fc..28ac1dfeb082 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6914,7 +6914,6 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
// Do not warn when all the elements in the initializer are concatenated
// together. Do not warn for macros too.
if (NumConcat > 1 && E > 2 && !SL->getBeginLoc().isMacroID() &&
- SL->getString().find(" ") == llvm::StringRef::npos &&
isa<StringLiteral>(InitArgList[0]) && SLPrev &&
NumConcat != SLPrev->getNumConcatenated()) {
SmallVector<FixItHint, 1> Hints;
diff --git a/clang/test/Sema/string-concat.c b/clang/test/Sema/string-concat.c
index 09de0a9bffbe..4e5ed4424e7c 100644
--- a/clang/test/Sema/string-concat.c
+++ b/clang/test/Sema/string-concat.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -Wstring-concatenation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -Wstring-concatenation -fsyntax-only -verify %s
const char *missing_comma[] = {
"basic_filebuf",
@@ -110,19 +110,6 @@ const char *not_warn2[] = {
"// Aaa\\\r" " Bbb\\ \r" " Ccc?" "?/\r"
};
-const char *not_warn3[] = {
- "// \\param [in,out] aaa Bbb\n",
- "// \\param[in,out] aaa Bbb\n",
- "// \\param [in, out] aaa Bbb\n",
- "// \\param [in,\n"
- "// out] aaa Bbb\n",
- "// \\param [in,out]\n"
- "// aaa Bbb\n",
- "// \\param [in,out] aaa\n"
- "// Bbb\n"
-};
-
-
// Do not warn when all the elements in the initializer are concatenated together.
const char *all_elems_in_init_concatenated[] = {"a" "b" "c"};
More information about the cfe-commits
mailing list