[clang-tools-extra] r218573 - [clang-tidy] Updated documentation

Alexander Kornienko alexfh at google.com
Sat Sep 27 14:47:02 PDT 2014


Author: alexfh
Date: Sat Sep 27 16:47:01 2014
New Revision: 218573

URL: http://llvm.org/viewvc/llvm-project?rev=218573&view=rev
Log:
[clang-tidy] Updated documentation

Added an example of check-specific options.

Modified:
    clang-tools-extra/trunk/docs/clang-tidy.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy.rst?rev=218573&r1=218572&r2=218573&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy.rst Sat Sep 27 16:47:01 2014
@@ -374,18 +374,33 @@ the check implements and what the curren
 .. code-block:: c++
 
   class MyCheck : public ClangTidyCheck {
-    const unsigned SomeOption;
+    const unsigned SomeOption1;
+    const std::string SomeOption2;
   
   public:
     MyCheck(StringRef Name, ClangTidyContext *Context)
       : ClangTidyCheck(Name, Context),
-        SomeOption(Options.get("SomeOption", -1U)) {}
+        SomeOption(Options.get("SomeOption1", -1U)),
+        SomeOption(Options.get("SomeOption2", "some default")) {}
 
     void storeOptions(ClangTidyOptions::OptionMap &Opts) {
-      Options.store(Opts, "SomeOption", SomeOption);
+      Options.store(Opts, "SomeOption1", SomeOption1);
+      Options.store(Opts, "SomeOption2", SomeOption2);
     }
     ...
 
+Assuming the check is registered with the name "my-check", the option can then
+be set in a ``.clang-tidy`` file in the following way:
+
+.. code-block:: yaml
+
+  CheckOptions: {
+    - key: my-check.SomeOption1
+      value: 123
+    - key: my-check.SomeOption2
+      value: 'some other value'
+  }
+
 
 Running clang-tidy on LLVM
 --------------------------





More information about the cfe-commits mailing list