[clang-tools-extra] r265375 - [clang-tidy] Fix documentation of misc-suspicious-missing-comma
Etienne Bergeron via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 4 18:41:02 PDT 2016
Author: etienneb
Date: Mon Apr 4 20:41:02 2016
New Revision: 265375
URL: http://llvm.org/viewvc/llvm-project?rev=265375&view=rev
Log:
[clang-tidy] Fix documentation of misc-suspicious-missing-comma
Summary:
The clang-tidy documentation generation was broken since commit : http://reviews.llvm.org/D18457
I ran locally the documentation generation and I fixed errors related to that specific check.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D18764
Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst?rev=265375&r1=265374&r2=265375&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst Mon Apr 4 20:41:02 2016
@@ -7,14 +7,19 @@ String literals placed side-by-side are
(after the preprocessor). This feature is used to represent long string
literal on multiple lines.
-For instance, these declarations are equivalent:
+For instance, the following declarations are equivalent:
+
+.. code:: c++
+
const char* A[] = "This is a test";
- const char* B[] = "This" " is a "
- "test";
+ const char* B[] = "This" " is a " "test";
+
A common mistake done by programmers is to forget a comma between two string
literals in an array initializer list.
+.. code:: c++
+
const char* Test[] = {
"line 1",
"line 2" // Missing comma!
@@ -23,13 +28,17 @@ literals in an array initializer list.
"line 5"
};
+
The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang
won't generate warnings at compile time.
This checker may warn incorrectly on cases like:
+.. code:: c++
+
const char* SupportedFormat[] = {
"Error %s",
"Code " PRIu64, // May warn here.
"Warning %s",
};
+
More information about the cfe-commits
mailing list