diff options
Diffstat (limited to 'clang-tools-extra/test')
75 files changed, 1334 insertions, 1205 deletions
diff --git a/clang-tools-extra/test/clang-doc/assets.cpp b/clang-tools-extra/test/clang-doc/assets.cpp index c5933e5..853dfe5 100644 --- a/clang-tools-extra/test/clang-doc/assets.cpp +++ b/clang-tools-extra/test/clang-doc/assets.cpp @@ -1,19 +1,7 @@ // RUN: rm -rf %t && mkdir %t // RUN: clang-doc --format=html --output=%t --asset=%S/Inputs/test-assets --executor=standalone %s --base base_dir -// RUN: FileCheck %s -input-file=%t/index.html -check-prefix=INDEX -// RUN: FileCheck %s -input-file=%t/test.css -check-prefix=CSS -// RUN: FileCheck %s -input-file=%t/test.js -check-prefix=JS - -// INDEX: <!DOCTYPE html> -// INDEX-NEXT: <meta charset="utf-8"/> -// INDEX-NEXT: <title>Index</title> -// INDEX-NEXT: <link rel="stylesheet" href="test.css"/> -// INDEX-NEXT: <script src="index_json.js"></script> -// INDEX-NEXT: <script src="test.js"></script> -// INDEX-NEXT: <header id="project-title"></header> -// INDEX-NEXT: <main> -// INDEX-NEXT: <div id="sidebar-left" path="" class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left" style="flex: 0 100%;"></div> -// INDEX-NEXT: </main> +// RUN: FileCheck %s -input-file=%t/html/test.css -check-prefix=CSS +// RUN: FileCheck %s -input-file=%t/html/test.js -check-prefix=JS // CSS: body { // CSS-NEXT: padding: 0; diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test b/clang-tools-extra/test/clang-doc/basic-project.mustache.test index 5509951..b985a392 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test +++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test @@ -1,18 +1,18 @@ // RUN: rm -rf %t && mkdir -p %t/docs %t/build // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json -// RUN: clang-doc --format=mustache --output=%t/docs --executor=all-TUs %t/build/compile_commands.json -// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV5Shape.html -check-prefix=HTML-SHAPE -// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV10Calculator.html -check-prefix=HTML-CALC -// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV9Rectangle.html -check-prefix=HTML-RECTANGLE -// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV6Circle.html -check-prefix=HTML-CIRCLE +// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json +// RUN: FileCheck %s -input-file=%t/docs/html/GlobalNamespace/_ZTV5Shape.html -check-prefix=HTML-SHAPE +// RUN: FileCheck %s -input-file=%t/docs/html/GlobalNamespace/_ZTV10Calculator.html -check-prefix=HTML-CALC +// RUN: FileCheck %s -input-file=%t/docs/html/GlobalNamespace/_ZTV9Rectangle.html -check-prefix=HTML-RECTANGLE +// RUN: FileCheck %s -input-file=%t/docs/html/GlobalNamespace/_ZTV6Circle.html -check-prefix=HTML-CIRCLE HTML-SHAPE: <html lang="en-US"> HTML-SHAPE: <head> HTML-SHAPE: <meta charset="utf-8"/> HTML-SHAPE: <title>Shape</title> -HTML-SHAPE: <link rel="stylesheet" type="text/css" href="./clang-doc-mustache.css"/> -HTML-SHAPE: <script src="./mustache-index.js"></script> +HTML-SHAPE: <link rel="stylesheet" type="text/css" href="../clang-doc-mustache.css"/> +HTML-SHAPE: <script src="../mustache-index.js"></script> HTML-SHAPE: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> HTML-SHAPE: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> HTML-SHAPE: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> @@ -60,84 +60,54 @@ HTML-SHAPE: <div class="content"> HTML-SHAPE: <section class="hero section-container"> HTML-SHAPE: <div class="hero__title"> HTML-SHAPE: <h1 class="hero__title-large">class Shape</h1> -HTML-SHAPE: <div class="hero__subtitle"> -HTML-SHAPE: <div> -HTML-SHAPE: <p> Abstract base class for shapes.</p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p></p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p> Provides a common interface for different types of shapes.</p> -HTML-SHAPE: </div> -HTML-SHAPE: </div> +HTML-SHAPE: <div class="hero__subtitle"> +HTML-SHAPE: <div> +HTML-SHAPE: <p> Abstract base class for shapes.</p> +HTML-SHAPE: </div> +HTML-SHAPE: <div> +HTML-SHAPE: <p> Provides a common interface for different types of shapes.</p> +HTML-SHAPE: </div> +HTML-SHAPE: </div> HTML-SHAPE: </div> HTML-SHAPE: </section> HTML-SHAPE: <section id="PublicMethods" class="section-container"> HTML-SHAPE: <h2>Public Methods</h2> HTML-SHAPE: <div> -HTML-SHAPE: <div class="delimiter-container"> -HTML-SHAPE: <div id="{{([0-9A-F]{40})}}"> -HTML-SHAPE: <pre> -HTML-SHAPE: <code class="language-cpp code-clang-doc"> -HTML-SHAPE: double area () -HTML-SHAPE: </code> -HTML-SHAPE: </pre> -HTML-SHAPE: <div> -HTML-SHAPE: <div> -HTML-SHAPE: <p> Calculates the area of the shape.</p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p></p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p></p> -HTML-SHAPE: </div> -HTML-SHAPE: <h3>Returns</h3> -HTML-SHAPE: <p> double The area of the shape.</p> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: <div class="delimiter-container"> -HTML-SHAPE: <div id="{{([0-9A-F]{40})}}"> -HTML-SHAPE: <pre> -HTML-SHAPE: <code class="language-cpp code-clang-doc"> -HTML-SHAPE: double perimeter () -HTML-SHAPE: </code> -HTML-SHAPE: </pre> -HTML-SHAPE: <div> -HTML-SHAPE: <div> -HTML-SHAPE: <p> Calculates the perimeter of the shape.</p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p></p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p></p> -HTML-SHAPE: </div> -HTML-SHAPE: <h3>Returns</h3> -HTML-SHAPE: <p> double The perimeter of the shape.</p> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: <div class="delimiter-container"> -HTML-SHAPE: <div id="{{([0-9A-F]{40})}}"> -HTML-SHAPE: <pre> -HTML-SHAPE: <code class="language-cpp code-clang-doc"> -HTML-SHAPE: void ~Shape () -HTML-SHAPE: </code> -HTML-SHAPE: </pre> -HTML-SHAPE: <div> -HTML-SHAPE: <div> -HTML-SHAPE: <p> Virtual destructor.</p> -HTML-SHAPE: </div> -HTML-SHAPE: <div> -HTML-SHAPE: <p></p> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: </div> -HTML-SHAPE: </div> +HTML-SHAPE: <div class="delimiter-container"> +HTML-SHAPE: <div id="{{([0-9A-F]{40})}}"> +HTML-SHAPE: <pre><code class="language-cpp code-clang-doc">double area ()</code></pre> +HTML-SHAPE: <div> +HTML-SHAPE: <div> +HTML-SHAPE: <p> Calculates the area of the shape.</p> +HTML-SHAPE: </div> +HTML-SHAPE: <h3>Returns</h3> +HTML-SHAPE: <p> double The area of the shape.</p> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: <div class="delimiter-container"> +HTML-SHAPE: <div id="{{([0-9A-F]{40})}}"> +HTML-SHAPE: <pre><code class="language-cpp code-clang-doc">double perimeter ()</code></pre> +HTML-SHAPE: <div> +HTML-SHAPE: <div> +HTML-SHAPE: <p> Calculates the perimeter of the shape.</p> +HTML-SHAPE: </div> +HTML-SHAPE: <h3>Returns</h3> +HTML-SHAPE: <p> double The perimeter of the shape.</p> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: <div class="delimiter-container"> +HTML-SHAPE: <div id="{{([0-9A-F]{40})}}"> +HTML-SHAPE: <pre><code class="language-cpp code-clang-doc">void ~Shape ()</code></pre> +HTML-SHAPE: <div> +HTML-SHAPE: <div> +HTML-SHAPE: <p> Virtual destructor.</p> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: </div> +HTML-SHAPE: </div> HTML-SHAPE: </section> HTML-SHAPE: </div> HTML-SHAPE: </div> @@ -151,8 +121,8 @@ HTML-CALC: <html lang="en-US"> HTML-CALC: <head> HTML-CALC: <meta charset="utf-8"/> HTML-CALC: <title>Calculator</title> -HTML-CALC: <link rel="stylesheet" type="text/css" href="./clang-doc-mustache.css"/> -HTML-CALC: <script src="./mustache-index.js"></script> +HTML-CALC: <link rel="stylesheet" type="text/css" href="../clang-doc-mustache.css"/> +HTML-CALC: <script src="../mustache-index.js"></script> HTML-CALC: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> HTML-CALC: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> HTML-CALC: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> @@ -217,216 +187,130 @@ HTML-CALC: <div class="content"> HTML-CALC: <section class="hero section-container"> HTML-CALC: <div class="hero__title"> HTML-CALC: <h1 class="hero__title-large">class Calculator</h1> -HTML-CALC: <div> -HTML-CALC: <p> A simple calculator class.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p> Provides basic arithmetic operations.</p> -HTML-CALC: </div> -HTML-CALC: </div> +HTML-CALC: <div class="hero__subtitle"> +HTML-CALC: <div> +HTML-CALC: <p> A simple calculator class.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p> Provides basic arithmetic operations.</p> +HTML-CALC: </div> +HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </section> HTML-CALC: <section id="PublicMembers" class="section-container"> HTML-CALC: <h2>Public Members</h2> HTML-CALC: <div> HTML-CALC: <div id="public_val" class="delimiter-container"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc" >int public_val</code> -HTML-CALC: </pre> +HTML-CALC: <pre><code class="language-cpp code-clang-doc" >int public_val</code></pre> HTML-CALC: </div> HTML-CALC: <div id="static_val" class="delimiter-container"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc" >const int static_val</code> -HTML-CALC: </pre> +HTML-CALC: <pre><code class="language-cpp code-clang-doc" >const int static_val</code></pre> HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </section> HTML-CALC: <section id="PublicMethods" class="section-container"> HTML-CALC: <h2>Public Methods</h2> HTML-CALC: <div> -HTML-CALC: <div class="delimiter-container"> -HTML-CALC: <div id="{{([0-9A-F]{40})}}"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc"> -HTML-CALC: int add (int a, int b) -HTML-CALC: </code> -HTML-CALC: </pre> -HTML-CALC: <div> -HTML-CALC: <div> -HTML-CALC: <p> Adds two integers.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <h3>Parameters</h3> -HTML-CALC: <div> -HTML-CALC: <b>a</b> <div> -HTML-CALC: <p> First integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <b>b</b> <div> -HTML-CALC: <p> Second integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <h3>Returns</h3> -HTML-CALC: <p> int The sum of a and b.</p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div class="delimiter-container"> -HTML-CALC: <div id="{{([0-9A-F]{40})}}"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc"> -HTML-CALC: int subtract (int a, int b) -HTML-CALC: </code> -HTML-CALC: </pre> -HTML-CALC: <div> -HTML-CALC: <div> -HTML-CALC: <p> Subtracts the second integer from the first.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <h3>Returns</h3> -HTML-CALC: <p> int The result of a - b.</p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div class="delimiter-container"> -HTML-CALC: <div id="{{([0-9A-F]{40})}}"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc"> -HTML-CALC: int multiply (int a, int b) -HTML-CALC: </code> -HTML-CALC: </pre> -HTML-CALC: <div> -HTML-CALC: <div> -HTML-CALC: <p> Multiplies two integers.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <h3>Parameters</h3> -HTML-CALC: <div> -HTML-CALC: <b>a</b> <div> -HTML-CALC: <p> First integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <b>b</b> <div> -HTML-CALC: <p> Second integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <h3>Returns</h3> -HTML-CALC: <p> int The product of a and b.</p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div class="delimiter-container"> -HTML-CALC: <div id="{{([0-9A-F]{40})}}"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc"> -HTML-CALC: double divide (int a, int b) -HTML-CALC: </code> -HTML-CALC: </pre> -HTML-CALC: <div> -HTML-CALC: <div> -HTML-CALC: <p> Divides the first integer by the second.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <h3>Parameters</h3> -HTML-CALC: <div> -HTML-CALC: <b>a</b> <div> -HTML-CALC: <p> First integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <b>b</b> <div> -HTML-CALC: <p> Second integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <h3>Returns</h3> -HTML-CALC: <p> double The result of a / b.</p> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div class="delimiter-container"> -HTML-CALC: <div id="{{([0-9A-F]{40})}}"> -HTML-CALC: <pre> -HTML-CALC: <code class="language-cpp code-clang-doc"> -HTML-CALC: int mod (int a, int b) -HTML-CALC: </code> -HTML-CALC: </pre> -HTML-CALC: <div> -HTML-CALC: <div> -HTML-CALC: <p> Performs the mod operation on integers.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: <h3>Parameters</h3> -HTML-CALC: <div> -HTML-CALC: <b>a</b> <div> -HTML-CALC: <p> First integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <b>b</b> <div> -HTML-CALC: <p> Second integer.</p> -HTML-CALC: </div> -HTML-CALC: <div> -HTML-CALC: <p></p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: <h3>Returns</h3> -HTML-CALC: <p> The result of a % b.</p> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: </div> -HTML-CALC: </div> +HTML-CALC: <div class="delimiter-container"> +HTML-CALC: <div id="{{([0-9A-F]{40})}}"> +HTML-CALC: <pre><code class="language-cpp code-clang-doc">int add (int a, int b)</code></pre> +HTML-CALC: <div> +HTML-CALC: <div> +HTML-CALC: <p> Adds two integers.</p> +HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> First integer. +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> Second integer. +HTML-CALC: </div> +HTML-CALC: <h3>Returns</h3> +HTML-CALC: <p> int The sum of a and b.</p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div class="delimiter-container"> +HTML-CALC: <div id="{{([0-9A-F]{40})}}"> +HTML-CALC: <pre><code class="language-cpp code-clang-doc">int subtract (int a, int b)</code></pre> +HTML-CALC: <div> +HTML-CALC: <div> +HTML-CALC: <p> Subtracts the second integer from the first.</p> +HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> First integer. +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> Second integer. +HTML-CALC: </div> +HTML-CALC: <h3>Returns</h3> +HTML-CALC: <p> int The result of a - b.</p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div class="delimiter-container"> +HTML-CALC: <div id="{{([0-9A-F]{40})}}"> +HTML-CALC: <pre><code class="language-cpp code-clang-doc">int multiply (int a, int b)</code></pre> +HTML-CALC: <div> +HTML-CALC: <div> +HTML-CALC: <p> Multiplies two integers.</p> +HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> First integer. +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> Second integer. +HTML-CALC: </div> +HTML-CALC: <h3>Returns</h3> +HTML-CALC: <p> int The product of a and b.</p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div class="delimiter-container"> +HTML-CALC: <div id="{{([0-9A-F]{40})}}"> +HTML-CALC: <pre><code class="language-cpp code-clang-doc">double divide (int a, int b)</code></pre> +HTML-CALC: <div> +HTML-CALC: <div> +HTML-CALC: <p> Divides the first integer by the second.</p> +HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> First integer. +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> Second integer. +HTML-CALC: </div> +HTML-CALC: <h3>Returns</h3> +HTML-CALC: <p> double The result of a / b.</p> +HTML-CALC: <h3>Throws</h3> +HTML-CALC: <div> +HTML-CALC: <b>std::invalid_argument</b> if b is zero. +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div class="delimiter-container"> +HTML-CALC: <div id="{{([0-9A-F]{40})}}"> +HTML-CALC: <pre><code class="language-cpp code-clang-doc">int mod (int a, int b)</code></pre> +HTML-CALC: <div> +HTML-CALC: <div> +HTML-CALC: <p> Performs the mod operation on integers.</p> +HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> First integer. +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> Second integer. +HTML-CALC: </div> +HTML-CALC: <h3>Returns</h3> +HTML-CALC: <p> The result of a % b.</p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: </div> HTML-CALC: </section> HTML-CALC: </div> HTML-CALC: </div> @@ -435,13 +319,14 @@ HTML-CALC: </body> HTML-CALC: </html> + HTML-RECTANGLE: <!DOCTYPE html> HTML-RECTANGLE: <html lang="en-US"> HTML-RECTANGLE: <head> HTML-RECTANGLE: <meta charset="utf-8"/> HTML-RECTANGLE: <title>Rectangle</title> -HTML-RECTANGLE: <link rel="stylesheet" type="text/css" href="./clang-doc-mustache.css"/> -HTML-RECTANGLE: <script src="./mustache-index.js"></script> +HTML-RECTANGLE: <link rel="stylesheet" type="text/css" href="../clang-doc-mustache.css"/> +HTML-RECTANGLE: <script src="../mustache-index.js"></script> HTML-RECTANGLE: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> HTML-RECTANGLE: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> HTML-RECTANGLE: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> @@ -489,101 +374,61 @@ HTML-RECTANGLE: <div class="content"> HTML-RECTANGLE: <section class="hero section-container"> HTML-RECTANGLE: <div class="hero__title"> HTML-RECTANGLE: <h1 class="hero__title-large">class Rectangle</h1> -HTML-RECTANGLE: <div class="hero__subtitle"> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p> Rectangle class derived from Shape.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p> Represents a rectangle with a given width and height.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div class="hero__subtitle"> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <p> Rectangle class derived from Shape.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <p> Represents a rectangle with a given width and height.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> HTML-RECTANGLE: </div> HTML-RECTANGLE: </section> HTML-RECTANGLE: <section id="PublicMethods" class="section-container"> HTML-RECTANGLE: <h2>Public Methods</h2> HTML-RECTANGLE: <div> -HTML-RECTANGLE: <div class="delimiter-container"> -HTML-RECTANGLE: <div id="{{([0-9A-F]{40})}}"> -HTML-RECTANGLE: <pre> -HTML-RECTANGLE: <code class="language-cpp code-clang-doc"> -HTML-RECTANGLE: void Rectangle (double width, double height) -HTML-RECTANGLE: </code> -HTML-RECTANGLE: </pre> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p> Constructs a new Rectangle object.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <h3>Parameters</h3> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <b>width</b> <div> -HTML-RECTANGLE: <p> Width of the rectangle.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <b>height</b> <div> -HTML-RECTANGLE: <p> Height of the rectangle.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div class="delimiter-container"> -HTML-RECTANGLE: <div id="{{([0-9A-F]{40})}}"> -HTML-RECTANGLE: <pre> -HTML-RECTANGLE: <code class="language-cpp code-clang-doc"> -HTML-RECTANGLE: double area () -HTML-RECTANGLE: </code> -HTML-RECTANGLE: </pre> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p> Calculates the area of the rectangle.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <h3>Returns</h3> -HTML-RECTANGLE: <p> double The area of the rectangle.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div class="delimiter-container"> -HTML-RECTANGLE: <div id="{{([0-9A-F]{40})}}"> -HTML-RECTANGLE: <pre> -HTML-RECTANGLE: <code class="language-cpp code-clang-doc"> -HTML-RECTANGLE: double perimeter () -HTML-RECTANGLE: </code> -HTML-RECTANGLE: </pre> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p> Calculates the perimeter of the rectangle.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <div> -HTML-RECTANGLE: <p></p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: <h3>Returns</h3> -HTML-RECTANGLE: <p> double The perimeter of the rectangle.</p> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> -HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div class="delimiter-container"> +HTML-RECTANGLE: <div id="{{([0-9A-F]{40})}}"> +HTML-RECTANGLE: <pre><code class="language-cpp code-clang-doc">void Rectangle (double width, double height)</code></pre> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <p> Constructs a new Rectangle object.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <h3>Parameters</h3> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <b>width</b> Width of the rectangle. +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <b>height</b> Height of the rectangle. +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div class="delimiter-container"> +HTML-RECTANGLE: <div id="{{([0-9A-F]{40})}}"> +HTML-RECTANGLE: <pre><code class="language-cpp code-clang-doc">double area ()</code></pre> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <p> Calculates the area of the rectangle.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <h3>Returns</h3> +HTML-RECTANGLE: <p> double The area of the rectangle.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div class="delimiter-container"> +HTML-RECTANGLE: <div id="{{([0-9A-F]{40})}}"> +HTML-RECTANGLE: <pre><code class="language-cpp code-clang-doc">double perimeter ()</code></pre> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <p> Calculates the perimeter of the rectangle.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <h3>Returns</h3> +HTML-RECTANGLE: <p> double The perimeter of the rectangle.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> HTML-RECTANGLE: </section> HTML-RECTANGLE: </div> HTML-RECTANGLE: </div> @@ -592,13 +437,14 @@ HTML-RECTANGLE: </body> HTML-RECTANGLE: </html> + HTML-CIRCLE: <!DOCTYPE html> HTML-CIRCLE: <html lang="en-US"> HTML-CIRCLE: <head> HTML-CIRCLE: <meta charset="utf-8"/> HTML-CIRCLE: <title>Circle</title> -HTML-CIRCLE: <link rel="stylesheet" type="text/css" href="./clang-doc-mustache.css"/> -HTML-CIRCLE: <script src="./mustache-index.js"></script> +HTML-CIRCLE: <link rel="stylesheet" type="text/css" href="../clang-doc-mustache.css"/> +HTML-CIRCLE: <script src="../mustache-index.js"></script> HTML-CIRCLE: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> HTML-CIRCLE: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> HTML-CIRCLE: <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> @@ -646,102 +492,67 @@ HTML-CIRCLE: <div class="content"> HTML-CIRCLE: <section class="hero section-container"> HTML-CIRCLE: <div class="hero__title"> HTML-CIRCLE: <h1 class="hero__title-large">class Circle</h1> -HTML-CIRCLE: <div class="hero__subtitle"> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p> Circle class derived from Shape.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p> Represents a circle with a given radius.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> +HTML-CIRCLE: <div class="hero__subtitle"> +HTML-CIRCLE: <div> +HTML-CIRCLE: <p> Circle class derived from Shape.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: <div> +HTML-CIRCLE: <p> Represents a circle with a given radius.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> HTML-CIRCLE: </div> HTML-CIRCLE: </section> HTML-CIRCLE: <section id="PublicMethods" class="section-container"> HTML-CIRCLE: <h2>Public Methods</h2> HTML-CIRCLE: <div> -HTML-CIRCLE: <div class="delimiter-container"> -HTML-CIRCLE: <div id="{{([0-9A-F]{40})}}"> -HTML-CIRCLE: <pre> -HTML-CIRCLE: <code class="language-cpp code-clang-doc"> -HTML-CIRCLE: void Circle (double radius) -HTML-CIRCLE: </code> -HTML-CIRCLE: </pre> -HTML-CIRCLE: <div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p> Constructs a new Circle object.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <h3>Parameters</h3> -HTML-CIRCLE: <div> -HTML-CIRCLE: <b>radius</b> <div> -HTML-CIRCLE: <p> Radius of the circle.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div class="delimiter-container"> -HTML-CIRCLE: <div id="{{([0-9A-F]{40})}}"> -HTML-CIRCLE: <pre> -HTML-CIRCLE: <code class="language-cpp code-clang-doc"> -HTML-CIRCLE: double area () -HTML-CIRCLE: </code> -HTML-CIRCLE: </pre> -HTML-CIRCLE: <div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p> Calculates the area of the circle.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <h3>Returns</h3> -HTML-CIRCLE: <p> double The area of the circle.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div class="delimiter-container"> -HTML-CIRCLE: <div id="{{([0-9A-F]{40})}}"> -HTML-CIRCLE: <pre> -HTML-CIRCLE: <code class="language-cpp code-clang-doc"> -HTML-CIRCLE: double perimeter () -HTML-CIRCLE: </code> -HTML-CIRCLE: </pre> -HTML-CIRCLE: <div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p> Calculates the perimeter of the circle.</p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <div> -HTML-CIRCLE: <p></p> -HTML-CIRCLE: </div> -HTML-CIRCLE: <h3>Returns</h3> -HTML-CIRCLE: <p> double The perimeter of the circle.</p> -HTML-CIRCLE: <h3>Code</h3> -HTML-CIRCLE: <div> -HTML-CIRCLE: <pre class="code-block"> -HTML-CIRCLE: <code> -HTML-CIRCLE: Circle circle(5.0); -HTML-CIRCLE: double perimeter = circle.perimeter(); -HTML-CIRCLE: </code> -HTML-CIRCLE: </pre> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> -HTML-CIRCLE: </div> +HTML-CIRCLE: <div class="delimiter-container"> +HTML-CIRCLE: <div id="{{([0-9A-F]{40})}}"> +HTML-CIRCLE: <pre><code class="language-cpp code-clang-doc">void Circle (double radius)</code></pre> +HTML-CIRCLE: <div> +HTML-CIRCLE: <div> +HTML-CIRCLE: <p> Constructs a new Circle object.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: <h3>Parameters</h3> +HTML-CIRCLE: <div> +HTML-CIRCLE: <b>radius</b> Radius of the circle. +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: <div class="delimiter-container"> +HTML-CIRCLE: <div id="{{([0-9A-F]{40})}}"> +HTML-CIRCLE: <pre><code class="language-cpp code-clang-doc">double area ()</code></pre> +HTML-CIRCLE: <div> +HTML-CIRCLE: <div> +HTML-CIRCLE: <p> Calculates the area of the circle.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: <h3>Returns</h3> +HTML-CIRCLE: <p> double The area of the circle.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: <div class="delimiter-container"> +HTML-CIRCLE: <div id="{{([0-9A-F]{40})}}"> +HTML-CIRCLE: <pre><code class="language-cpp code-clang-doc">double perimeter ()</code></pre> +HTML-CIRCLE: <div> +HTML-CIRCLE: <div> +HTML-CIRCLE: <p> Calculates the perimeter of the circle.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: <h3>Returns</h3> +HTML-CIRCLE: <p> double The perimeter of the circle.</p> +HTML-CIRCLE: <h3>Code</h3> +HTML-CIRCLE: <div> +HTML-CIRCLE: <pre class="code-block"> +HTML-CIRCLE: <code> +HTML-CIRCLE: Circle circle(5.0); +HTML-CIRCLE: double perimeter = circle.perimeter(); +HTML-CIRCLE: </code> +HTML-CIRCLE: </pre> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> HTML-CIRCLE: </section> HTML-CIRCLE: </div> HTML-CIRCLE: </div> diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index 9c1ed29..9220dc6 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -1,31 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t/docs %t/build // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json -// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json -// RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Shape.html -check-prefix=HTML-SHAPE -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Calculator.html -check-prefix=HTML-CALC -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Rectangle.html -check-prefix=HTML-RECTANGLE -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Circle.html -check-prefix=HTML-CIRCLE - -// RUN: clang-doc --format=html --output=%t/docs-with-prefix --executor=all-TUs %t/build/compile_commands.json --repository=https://repository.com --repository-line-prefix=L -// RUN: FileCheck %s -input-file=%t/docs-with-prefix/GlobalNamespace/Shape.html -check-prefixes=HTML-SHAPE,SHAPE-LINE-PREFIX -// RUN: FileCheck %s -input-file=%t/docs-with-prefix/GlobalNamespace/Calculator.html -check-prefixes=HTML-CALC,CALC-LINE-PREFIX -// RUN: FileCheck %s -input-file=%t/docs-with-prefix/GlobalNamespace/Rectangle.html -check-prefixes=HTML-RECTANGLE,RECTANGLE-LINE-PREFIX -// RUN: FileCheck %s -input-file=%t/docs-with-prefix/GlobalNamespace/Circle.html -check-prefixes=HTML-CIRCLE,CIRCLE-LINE-PREFIX - -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Shape.html -check-prefixes=HTML-SHAPE,SHAPE-NO-REPOSITORY -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Calculator.html -check-prefixes=HTML-CALC,CALC-NO-REPOSITORY -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Rectangle.html -check-prefixes=HTML-RECTANGLE,RECTANGLE-NO-REPOSITORY -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Circle.html -check-prefixes=HTML-CIRCLE,CIRCLE-NO-REPOSITORY - -// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json --repository=https://repository.com -// RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefixes=JSON-INDEX -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Shape.html -check-prefixes=HTML-SHAPE,SHAPE-REPOSITORY -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Calculator.html -check-prefixes=HTML-CALC,CALC-REPOSITORY -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Rectangle.html -check-prefixes=HTML-RECTANGLE,RECTANGLE-REPOSITORY -// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Circle.html -check-prefixes=HTML-CIRCLE,CIRCLE-REPOSITORY - // RUN: clang-doc --format=md --output=%t/docs --executor=all-TUs %t/build/compile_commands.json // RUN: FileCheck %s -input-file=%t/docs/all_files.md -check-prefixes=MD-ALL-FILES // RUN: FileCheck %s -input-file=%t/docs/index.md -check-prefixes=MD-INDEX @@ -81,248 +56,6 @@ // JSON-INDEX-NEXT: }; // JSON-INDEX-NEXT: } -// HTML-SHAPE: <h1>class Shape</h1> -// SHAPE-NO-REPOSITORY: <p>Defined at line 8 of file .{{.}}include{{.}}Shape.h</p> -// SHAPE-REPOSITORY: <p> -// SHAPE-REPOSITORY-NEXT: Defined at line -// SHAPE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Shape.h#8">8</a> -// SHAPE-LINE-PREFIX: <a href="https://repository.com/./include/Shape.h#L8">8</a> -// SHAPE-REPOSITORY-NEXT: of file -// SHAPE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Shape.h">Shape.h</a> -// SHAPE-REPOSITORY-NEXT: </p> -// HTML-SHAPE: <div>brief</div> -// HTML-SHAPE: <p> Abstract base class for shapes.</p> -// HTML-SHAPE: <p> Provides a common interface for different types of shapes.</p> -// HTML-SHAPE: <h2 id="Functions">Functions</h2> -// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">area</h3> -// HTML-SHAPE: <p>public double area()</p> -// HTML-SHAPE: <div>brief</div> -// HTML-SHAPE: <p> Calculates the area of the shape.</p> -// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">perimeter</h3> -// HTML-SHAPE: <p>public double perimeter()</p> -// HTML-SHAPE: <div>brief</div> -// HTML-SHAPE: <p> Calculates the perimeter of the shape.</p> -// HTML-SHAPE: <div>return</div> -// HTML-SHAPE: <p> double The perimeter of the shape.</p> -// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">~Shape</h3> -// HTML-SHAPE: <p>public void ~Shape()</p> - -// SHAPE-NO-REPOSITORY: Defined at line 13 of file .{{.}}include{{.}}Shape.h -// SHAPE-REPOSITORY: Defined at line -// SHAPE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Shape.h#13">13</a> -// SHAPE-LINE-PREFIX: <a href="https://repository.com/./include/Shape.h#L13">13</a> -// SHAPE-REPOSITORY-NEXT: of file -// SHAPE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Shape.h">Shape.h</a> - -// HTML-SHAPE: <div>brief</div> -// HTML-SHAPE: <p> Virtual destructor.</p> - -// HTML-CALC: <h1>class Calculator</h1> -// CALC-NO-REPOSITORY: <p>Defined at line 8 of file .{{.}}include{{.}}Calculator.h</p> -// CALC-REPOSITORY: <p> -// CALC-REPOSITORY-NEXT: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./include/Calculator.h#8">8</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./include/Calculator.h#L8">8</a> -// CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./include/Calculator.h">Calculator.h</a> -// CALC-REPOSITORY-NEXT: </p> -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> A simple calculator class.</p> -// HTML-CALC: <p> Provides basic arithmetic operations.</p> - -// HTML-CALC: <h2 id="Members">Members</h2> -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> Holds a public value.</p> -// HTML-CALC: <div>public int public_val</div> -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> A static value.</p> -// HTML-CALC: <div>public static const int static_val</div> - -// HTML-CALC: <h2 id="Functions">Functions</h2> -// HTML-CALC: <h3 id="{{([0-9A-F]{40})}}">add</h3> -// HTML-CALC: <p>public int add(int a, int b)</p> -// CALC-NO-REPOSITORY: Defined at line 3 of file .{{.}}src{{.}}Calculator.cpp -// CALC-REPOSITORY: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#3">3</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L3">3</a> -// CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a> - -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> Adds two integers.</p> -// HTML-CALC: <div>return</div> -// HTML-CALC: <p> int The sum of a and b.</p> -// HTML-CALC: <h3 id="{{([0-9A-F]{40})}}">subtract</h3> -// HTML-CALC: <p>public int subtract(int a, int b)</p> -// CALC-NO-REPOSITORY: Defined at line 7 of file .{{.}}src{{.}}Calculator.cpp -// CALC-REPOSITORY: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#7">7</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L7">7</a> -// CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a> - -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> Subtracts the second integer from the first.</p> -// HTML-CALC: <div>return</div> -// HTML-CALC: <p> int The result of a - b.</p> -// HTML-CALC: <h3 id="{{([0-9A-F]{40})}}">multiply</h3> -// HTML-CALC: <p>public int multiply(int a, int b)</p> -// CALC-NO-REPOSITORY: Defined at line 11 of file .{{.}}src{{.}}Calculator.cpp -// CALC-REPOSITORY: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#11">11</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L11">11</a> -// CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a> - -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> Multiplies two integers.</p> -// HTML-CALC: <div>return</div> -// HTML-CALC: <p> int The product of a and b.</p> -// HTML-CALC: <h3 id="{{([0-9A-F]{40})}}">divide</h3> -// HTML-CALC: <p>public double divide(int a, int b)</p> -// CALC-NO-REPOSITORY: Defined at line 15 of file .{{.}}src{{.}}Calculator.cpp -// CALC-REPOSITORY: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#15">15</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L15">15</a> -// CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a> - -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> Divides the first integer by the second.</p> -// HTML-CALC: <div>return</div> -// HTML-CALC: <p> double The result of a / b.</p> -// HTML-CALC: <div>throw</div> -// HTML-CALC: <p>if b is zero.</p> - -// HTML-CALC: <p>public static int mod(int a, int b)</p> -// CALC-NO-REPOSITORY: Defined at line 54 of file .{{.}}include{{.}}Calculator.h -// CALC-REPOSITORY: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./include/Calculator.h#54">54</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./include/Calculator.h#L54">54</a> -// CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./include/Calculator.h">Calculator.h</a> -// HTML-CALC: <div>brief</div> -// HTML-CALC: <p> Performs the mod operation on integers.</p> -// HTML-CALC: <div>return</div> -// HTML-CALC: <p> The result of a % b.</p> - -// HTML-RECTANGLE: <h1>class Rectangle</h1> -// RECTANGLE-NO-REPOSITORY: <p>Defined at line 10 of file .{{.}}include{{.}}Rectangle.h</p> -// RECTANGLE-REPOSITORY: <p> -// RECTANGLE-REPOSITORY-NEXT: Defined at line -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Rectangle.h#10">10</a> -// RECTANGLE-LINE-PREFIX: <a href="https://repository.com/./include/Rectangle.h#L10">10</a> -// RECTANGLE-REPOSITORY-NEXT: of file -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Rectangle.h">Rectangle.h</a> -// RECTANGLE-REPOSITORY-NEXT: </p> - -// HTML-RECTANGLE: <p> Represents a rectangle with a given width and height.</p> -// HTML-RECTANGLE: <p> -// HTML-RECTANGLE: Inherits from -// HTML-RECTANGLE: <a href="Shape.html">Shape</a> -// HTML-RECTANGLE: </p> -// HTML-RECTANGLE: <h2 id="Members">Members</h2> -// HTML-RECTANGLE: <p> Width of the rectangle.</p> -// HTML-RECTANGLE: <div>private double width_</div> -// HTML-RECTANGLE: <p> Height of the rectangle.</p> -// HTML-RECTANGLE: <div>private double height_</div> -// HTML-RECTANGLE: <h2 id="Functions">Functions</h2> -// HTML-RECTANGLE: <h3 id="{{([0-9A-F]{40})}}">Rectangle</h3> -// HTML-RECTANGLE: <p>public void Rectangle(double width, double height)</p> -// RECTANGLE-NO-REPOSITORY: Defined at line 3 of file .{{.}}src{{.}}Rectangle.cpp -// RECTANGLE-REPOSITORY: Defined at line -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Rectangle.cpp#3">3</a> -// RECTANGLE-LINE-PREFIX: <a href="https://repository.com/./src/Rectangle.cpp#L3">3</a> -// RECTANGLE-REPOSITORY-NEXT: of file -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Rectangle.cpp">Rectangle.cpp</a> - -// HTML-RECTANGLE: <div>brief</div> -// HTML-RECTANGLE: <p> Constructs a new Rectangle object.</p> -// HTML-RECTANGLE: <h3 id="{{([0-9A-F]{40})}}">area</h3> -// HTML-RECTANGLE: <p>public double area()</p> -// RECTANGLE-NO-REPOSITORY: Defined at line 6 of file .{{.}}src{{.}}Rectangle.cpp -// RECTANGLE-REPOSITORY: Defined at line -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Rectangle.cpp#6">6</a> -// RECTANGLE-LINE-PREFIX: <a href="https://repository.com/./src/Rectangle.cpp#L6">6</a> -// RECTANGLE-REPOSITORY-NEXT: of file -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Rectangle.cpp">Rectangle.cpp</a> - -// HTML-RECTANGLE: <div>brief</div> -// HTML-RECTANGLE: <p> Calculates the area of the rectangle.</p> -// HTML-RECTANGLE: <div>return</div> -// HTML-RECTANGLE: <p> double The area of the rectangle.</p> -// HTML-RECTANGLE: <h3 id="{{([0-9A-F]{40})}}">perimeter</h3> -// HTML-RECTANGLE: <p>public double perimeter()</p> -// RECTANGLE-NO-REPOSITORY: Defined at line 10 of file .{{.}}src{{.}}Rectangle.cpp -// RECTANGLE-REPOSITORY: Defined at line -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Rectangle.cpp#10">10</a> -// RECTANGLE-LINE-PREFIX: <a href="https://repository.com/./src/Rectangle.cpp#L10">10</a> -// RECTANGLE-REPOSITORY-NEXT: of file -// RECTANGLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Rectangle.cpp">Rectangle.cpp</a> -// HTML-RECTANGLE: <div>brief</div> -// HTML-RECTANGLE: <p> Calculates the perimeter of the rectangle.</p> -// HTML-RECTANGLE: <div>return</div> -// HTML-RECTANGLE: <p> double The perimeter of the rectangle.</p> - -// HTML-CIRCLE: <h1>class Circle</h1> -// CIRCLE-NO-REPOSITORY: <p>Defined at line 10 of file .{{.}}include{{.}}Circle.h</p> -// CIRCLE-REPOSITORY: <p> -// CIRCLE-REPOSITORY-NEXT: Defined at line -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Circle.h#10">10</a> -// CIRCLE-LINE-PREFIX: <a href="https://repository.com/./include/Circle.h#L10">10</a> -// CIRCLE-REPOSITORY-NEXT: of file -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./include/Circle.h">Circle.h</a> -// CIRCLE-REPOSITORY-NEXT: </p> - -// HTML-CIRCLE: <div>brief</div> -// HTML-CIRCLE: <p> Circle class derived from Shape.</p> -// HTML-CIRCLE: <p> Represents a circle with a given radius.</p> -// HTML-CIRCLE: <p> -// HTML-CIRCLE: Inherits from -// HTML-CIRCLE: <a href="Shape.html">Shape</a> -// HTML-CIRCLE: </p> -// HTML-CIRCLE: <h2 id="Members">Members</h2> -// HTML-CIRCLE: <p> Radius of the circle.</p> -// HTML-CIRCLE: <div>private double radius_</div> -// HTML-CIRCLE: <h2 id="Functions">Functions</h2> -// HTML-CIRCLE: <h3 id="{{([0-9A-F]{40})}}">Circle</h3> -// HTML-CIRCLE: <p>public void Circle(double radius)</p> -// CIRCLE-NO-REPOSITORY: Defined at line 3 of file .{{.}}src{{.}}Circle.cpp -// CIRCLE-REPOSITORY: Defined at line -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Circle.cpp#3">3</a> -// CIRCLE-LINE-PREFIX: <a href="https://repository.com/./src/Circle.cpp#L3">3</a> -// CIRCLE-REPOSITORY-NEXT: of file -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Circle.cpp">Circle.cpp</a> - -// HTML-CIRCLE: <div>brief</div> -// HTML-CIRCLE: <p> Constructs a new Circle object.</p> -// HTML-CIRCLE: <h3 id="{{([0-9A-F]{40})}}">area</h3> -// HTML-CIRCLE: <p>public double area()</p> -// CIRCLE-NO-REPOSITORY: Defined at line 5 of file .{{.}}src{{.}}Circle.cpp -// CIRCLE-REPOSITORY: Defined at line -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Circle.cpp#5">5</a> -// CIRCLE-LINE-PREFIX: <a href="https://repository.com/./src/Circle.cpp#L5">5</a> -// CIRCLE-REPOSITORY-NEXT: of file -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Circle.cpp">Circle.cpp</a> - -// HTML-CIRCLE: <div>brief</div> -// HTML-CIRCLE: <p> Calculates the area of the circle.</p> -// HTML-CIRCLE: <div>return</div> -// HTML-CIRCLE: <p> double The area of the circle.</p> -// HTML-CIRCLE: <h3 id="{{([0-9A-F]{40})}}">perimeter</h3> -// HTML-CIRCLE: <p>public double perimeter()</p> -// CIRCLE-NO-REPOSITORY: Defined at line 9 of file .{{.}}src{{.}}Circle.cpp -// CIRCLE-REPOSITORY: Defined at line -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Circle.cpp#9">9</a> -// CIRCLE-LINE-PREFIX: <a href="https://repository.com/./src/Circle.cpp#L9">9</a> -// CIRCLE-REPOSITORY-NEXT: of file -// CIRCLE-REPOSITORY-NEXT: <a href="https://repository.com/./src/Circle.cpp">Circle.cpp</a> - -// HTML-CIRCLE: <div>brief</div> -// HTML-CIRCLE: <p> Calculates the perimeter of the circle.</p> -// HTML-CIRCLE: <div>return</div> -// HTML-CIRCLE: <p> double The perimeter of the circle.</p> - // MD-CALC: # class Calculator // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8* // MD-CALC: **brief** A simple calculator class. diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp index 0c70fad..bc0ec46 100644 --- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp +++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp @@ -6,8 +6,8 @@ // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS // RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s -// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS-LINE -// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS +// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV7MyClass.html --check-prefix=HTML-MYCLASS-LINE +// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV7MyClass.html --check-prefix=HTML-MYCLASS #define DECLARE_METHODS \ /** @@ -21,15 +21,18 @@ // MD-MYCLASS: *public int Add(int a, int b)* // MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers -// HTML-MYCLASS: <p>public int Add(int a, int b)</p> -// HTML-MYCLASS: <div>brief</div> -// HTML-MYCLASS: <p> Declare a method to calculate the sum of two numbers</p> + +// HTML-MYCLASS: <pre><code class="language-cpp code-clang-doc">int Add (int a, int b)</code></pre> +// HTML-MYCLASS: <div> +// HTML-MYCLASS: <div> +// HTML-MYCLASS: <p> Declare a method to calculate the sum of two numbers</p> +// HTML-MYCLASS: </div> class MyClass { public: -// MD-MYCLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp#[[@LINE+2]]* -// HTML-MYCLASS-LINE: <p>Defined at line [[@LINE+1]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp</p> +// MD-MYCLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp#[[@LINE-2]]* +// HTML-MYCLASS-LINE: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp</p> DECLARE_METHODS }; diff --git a/clang-tools-extra/test/clang-doc/conversion_function.cpp b/clang-tools-extra/test/clang-doc/conversion_function.cpp index 0200a57..63df5d6 100644 --- a/clang-tools-extra/test/clang-doc/conversion_function.cpp +++ b/clang-tools-extra/test/clang-doc/conversion_function.cpp @@ -4,7 +4,7 @@ // RUN: find %t/ -regex ".*/[0-9A-F]*.yaml" -exec cat {} ";" | FileCheck %s --check-prefix=CHECK-YAML // RUN: clang-doc --format=html --output=%t --executor=standalone %s -// RUN: FileCheck %s < %t/GlobalNamespace/MyStruct.html --check-prefix=CHECK-HTML +// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV8MyStruct.html --check-prefix=CHECK-HTML template <typename T> struct MyStruct { @@ -14,5 +14,6 @@ struct MyStruct { // Output correct conversion names. // CHECK-YAML: Name: 'operator T' -// CHECK-HTML: <h3 id="{{[0-9A-F]*}}">operator T</h3> -// CHECK-HTML: <p>public T operator T()</p> +// CHECK-HTML: <div id="{{([0-9A-F]{40})}}"> +// CHECK-HTML: <pre><code class="language-cpp code-clang-doc">T operator T ()</code></pre> +// CHECK-HTML: </div> diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp index b05d8e2..bb0d51f 100644 --- a/clang-tools-extra/test/clang-doc/enum.cpp +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -1,12 +1,12 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s // RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s -// RUN: FileCheck %s < %t/GlobalNamespace/index.html --check-prefix=HTML-INDEX-LINE -// RUN: FileCheck %s < %t/GlobalNamespace/index.html --check-prefix=HTML-INDEX -// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html --check-prefix=HTML-ANIMAL-LINE -// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html --check-prefix=HTML-ANIMAL -// RUN: FileCheck %s < %t/Vehicles/index.html --check-prefix=HTML-VEHICLES-LINE -// RUN: FileCheck %s < %t/Vehicles/index.html --check-prefix=HTML-VEHICLES +// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html --check-prefix=HTML-INDEX-LINE +// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html --check-prefix=HTML-INDEX +// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV7Animals.html --check-prefix=HTML-ANIMAL-LINE +// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV7Animals.html --check-prefix=HTML-ANIMAL +// RUN: FileCheck %s < %t/html/Vehicles/index.html --check-prefix=HTML-VEHICLES-LINE +// RUN: FileCheck %s < %t/html/Vehicles/index.html --check-prefix=HTML-VEHICLES // RUN: FileCheck %s < %t/GlobalNamespace/index.md --check-prefix=MD-INDEX-LINE // RUN: FileCheck %s < %t/GlobalNamespace/index.md --check-prefix=MD-INDEX // RUN: FileCheck %s < %t/GlobalNamespace/Animals.md --check-prefix=MD-ANIMAL-LINE @@ -14,12 +14,14 @@ // RUN: FileCheck %s < %t/Vehicles/index.md --check-prefix=MD-VEHICLES-LINE // RUN: FileCheck %s < %t/Vehicles/index.md --check-prefix=MD-VEHICLES +// COM: FIXME: Add enum value comments to template + /** * @brief For specifying RGB colors */ enum Color { // MD-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]* - // HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> + // HTML-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> Red, ///< Comment 1 Green, ///< Comment 2 Blue ///< Comment 3 @@ -33,23 +35,36 @@ enum Color { // MD-INDEX: | Blue | // MD-INDEX: **brief** For specifying RGB colors -// HTML-INDEX: <th colspan="3">enum Color</th> -// HTML-INDEX: <td>Red</td> -// HTML-INDEX: <td>0</td> -// HTML-INDEX: <p> Comment 1</p> -// HTML-INDEX: <td>Green</td> -// HTML-INDEX: <td>1</td> -// HTML-INDEX: <p> Comment 2</p> -// HTML-INDEX: <td>Blue</td> -// HTML-INDEX: <td>2</td> -// HTML-INDEX: <p> Comment 3</p> +// HTML-INDEX: <div> +// HTML-INDEX: <pre><code class="language-cpp code-clang-doc">enum Color</code></pre> +// HTML-INDEX: </div> +// HTML-INDEX: <table class="table-wrapper"> +// HTML-INDEX: <tbody> +// HTML-INDEX: <tr> +// HTML-INDEX: <th>Name</th> +// HTML-INDEX: <th>Value</th> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>Red</td> +// HTML-INDEX: <td>0</td> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>Green</td> +// HTML-INDEX: <td>1</td> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>Blue</td> +// HTML-INDEX: <td>2</td> +// HTML-INDEX: </tr> +// HTML-INDEX: </tbody> +// HTML-INDEX: </table> /** * @brief Shape Types */ enum class Shapes { // MD-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]* - // HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> + // HTML-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> /// Comment 1 Circle, @@ -65,17 +80,32 @@ enum class Shapes { // MD-INDEX: | Triangle | // MD-INDEX: **brief** Shape Types -// HTML-INDEX: <th colspan="3">enum class Shapes</th> -// HTML-INDEX: <td>Circle</td> -// HTML-INDEX: <td>0</td> -// HTML-INDEX: <p> Comment 1</p> -// HTML-INDEX: <td>Rectangle</td> -// HTML-INDEX: <td>1</td> -// HTML-INDEX: <p> Comment 2</p> -// HTML-INDEX: <td>Triangle</td> -// HTML-INDEX: <td>2</td> -// HTML-INDEX: <p> Comment 3</p> - +// COM: FIXME: Serialize "enum class" in template +// HTML-INDEX: <div> +// HTML-INDEX: <pre><code class="language-cpp code-clang-doc">enum Shapes</code></pre> +// HTML-INDEX: </div> +// HTML-INDEX: <table class="table-wrapper"> +// HTML-INDEX: <tbody> +// HTML-INDEX: <tr> +// HTML-INDEX: <th>Name</th> +// HTML-INDEX: <th>Value</th> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>Circle</td> +// HTML-INDEX: <td>0</td> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>Rectangle</td> +// HTML-INDEX: <td>1</td> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>Triangle</td> +// HTML-INDEX: <td>2</td> +// HTML-INDEX: </tr> +// HTML-INDEX: </tbody> +// HTML-INDEX: </table> + +// COM: FIXME: Add enums declared inside of classes to class template class Animals { // MD-ANIMAL-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]* // HTML-ANIMAL-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> @@ -85,25 +115,25 @@ public: */ enum AnimalType { // MD-ANIMAL-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]* - // HTML-ANIMAL-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> + // HTML-ANIMAL-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> Dog, ///< Man's best friend Cat, ///< Man's other best friend Iguana ///< A lizard }; }; -// HTML-ANIMAL: <h1>class Animals</h1> -// HTML-ANIMAL: <h2 id="Enums">Enums</h2> -// HTML-ANIMAL: <th colspan="3">enum AnimalType</th> -// HTML-ANIMAL: <td>Dog</td> -// HTML-ANIMAL: <td>0</td> -// HTML-ANIMAL: <p> Man's best friend</p> -// HTML-ANIMAL: <td>Cat</td> -// HTML-ANIMAL: <td>1</td> -// HTML-ANIMAL: <p> Man's other best friend</p> -// HTML-ANIMAL: <td>Iguana</td> -// HTML-ANIMAL: <td>2</td> -// HTML-ANIMAL: <p> A lizard</p> +// HTML-ANIMAL-NOT: <h1>class Animals</h1> +// HTML-ANIMAL-NOT: <h2 id="Enums">Enums</h2> +// HTML-ANIMAL-NOT: <th colspan="3">enum AnimalType</th> +// HTML-ANIMAL-NOT: <td>Dog</td> +// HTML-ANIMAL-NOT: <td>0</td> +// HTML-ANIMAL-NOT: <p> Man's best friend</p> +// HTML-ANIMAL-NOT: <td>Cat</td> +// HTML-ANIMAL-NOT: <td>1</td> +// HTML-ANIMAL-NOT: <p> Man's other best friend</p> +// HTML-ANIMAL-NOT: <td>Iguana</td> +// HTML-ANIMAL-NOT: <td>2</td> +// HTML-ANIMAL-NOT: <p> A lizard</p> // MD-ANIMAL: # class Animals // MD-ANIMAL: ## Enums @@ -120,7 +150,7 @@ namespace Vehicles { */ enum Car { // MD-VEHICLES-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]* - // HTML-VEHICLES-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> + // HTML-VEHICLES-LINE: Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp Sedan, ///< Comment 1 SUV, ///< Comment 2 @@ -139,20 +169,33 @@ enum Car { // MD-VEHICLES: | Hatchback | // MD-VEHICLES: **brief** specify type of car -// HTML-VEHICLES: <h1>namespace Vehicles</h1> -// HTML-VEHICLES: <th colspan="3">enum Car</th> -// HTML-VEHICLES: <td>Sedan</td> -// HTML-VEHICLES: <td>0</td> -// HTML-VEHICLES: <p> Comment 1</p> -// HTML-VEHICLES: <td>SUV</td> -// HTML-VEHICLES: <td>1</td> -// HTML-VEHICLES: <p> Comment 2</p> -// HTML-VEHICLES: <td>Pickup</td> -// HTML-VEHICLES: <td>2</td> -// HTML-VEHICLES: <p> Comment 3</p> -// HTML-VEHICLES: <td>Hatchback</td> -// HTML-VEHICLES: <td>3</td> -// HTML-VEHICLES: <p> Comment 4</p> +// HTML-VEHICLES: <div> +// HTML-VEHICLES: <pre><code class="language-cpp code-clang-doc">enum Car</code></pre> +// HTML-VEHICLES: </div> +// HTML-VEHICLES: <table class="table-wrapper"> +// HTML-VEHICLES: <tbody> +// HTML-VEHICLES: <tr> +// HTML-VEHICLES: <th>Name</th> +// HTML-VEHICLES: <th>Value</th> +// HTML-VEHICLES: </tr> +// HTML-VEHICLES: <tr> +// HTML-VEHICLES: <td>Sedan</td> +// HTML-VEHICLES: <td>0</td> +// HTML-VEHICLES: </tr> +// HTML-VEHICLES: <tr> +// HTML-VEHICLES: <td>SUV</td> +// HTML-VEHICLES: <td>1</td> +// HTML-VEHICLES: </tr> +// HTML-VEHICLES: <tr> +// HTML-VEHICLES: <td>Pickup</td> +// HTML-VEHICLES: <td>2</td> +// HTML-VEHICLES: </tr> +// HTML-VEHICLES: <tr> +// HTML-VEHICLES: <td>Hatchback</td> +// HTML-VEHICLES: <td>3</td> +// HTML-VEHICLES: </tr> +// HTML-VEHICLES: </tbody> +// HTML-VEHICLES: </table> enum ColorUserSpecified { RedUserSpecified = 'A', @@ -166,10 +209,26 @@ enum ColorUserSpecified { // MD-INDEX: | GreenUserSpecified | // MD-INDEX: | BlueUserSpecified | -// HTML-INDEX: <th colspan="2">enum ColorUserSpecified</th> -// HTML-INDEX: <td>RedUserSpecified</td> -// HTML-INDEX: <td>'A'</td> -// HTML-INDEX: <td>GreenUserSpecified</td> -// HTML-INDEX: <td>2</td> -// HTML-INDEX: <td>BlueUserSpecified</td> -// HTML-INDEX: <td>'C'</td> +// HTML-INDEX: <div> +// HTML-INDEX: <pre><code class="language-cpp code-clang-doc">enum ColorUserSpecified</code></pre> +// HTML-INDEX: </div> +// HTML-INDEX: <table class="table-wrapper"> +// HTML-INDEX: <tbody> +// HTML-INDEX: <tr> +// HTML-INDEX: <th>Name</th> +// HTML-INDEX: <th>Value</th> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>RedUserSpecified</td> +// HTML-INDEX: <td>'A'</td> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>GreenUserSpecified</td> +// HTML-INDEX: <td>2</td> +// HTML-INDEX: </tr> +// HTML-INDEX: <tr> +// HTML-INDEX: <td>BlueUserSpecified</td> +// HTML-INDEX: <td>'C'</td> +// HTML-INDEX: </tr> +// HTML-INDEX: </tbody> +// HTML-INDEX: </table> diff --git a/clang-tools-extra/test/clang-doc/json/class-requires.cpp b/clang-tools-extra/test/clang-doc/json/class-requires.cpp index 5139617..4e5ec3a 100644 --- a/clang-tools-extra/test/clang-doc/json/class-requires.cpp +++ b/clang-tools-extra/test/clang-doc/json/class-requires.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClass.json template<typename T> concept Addable = requires(T a, T b) { diff --git a/clang-tools-extra/test/clang-doc/json/class-specialization.cpp b/clang-tools-extra/test/clang-doc/json/class-specialization.cpp index d3ad695..60f3b44 100644 --- a/clang-tools-extra/test/clang-doc/json/class-specialization.cpp +++ b/clang-tools-extra/test/clang-doc/json/class-specialization.cpp @@ -1,7 +1,7 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json --check-prefix=BASE -// RUN: FileCheck %s < %t/json/_ZTV7MyClassIiE.json --check-prefix=SPECIALIZATION +// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClass.json --check-prefix=BASE +// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClassIiE.json --check-prefix=SPECIALIZATION template<typename T> struct MyClass {}; diff --git a/clang-tools-extra/test/clang-doc/json/class-template.cpp b/clang-tools-extra/test/clang-doc/json/class-template.cpp index 5ef78f54..de52064 100644 --- a/clang-tools-extra/test/clang-doc/json/class-template.cpp +++ b/clang-tools-extra/test/clang-doc/json/class-template.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClass.json template<typename T> struct MyClass { T MemberTemplate; diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp b/clang-tools-extra/test/clang-doc/json/class.cpp index 20a9f21..8bf9402 100644 --- a/clang-tools-extra/test/clang-doc/json/class.cpp +++ b/clang-tools-extra/test/clang-doc/json/class.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClass.json struct Foo; @@ -47,9 +47,6 @@ protected: // CHECK-NEXT: }, // CHECK-NEXT: { // CHECK-NEXT: "TextComment": " It has some nice methods and fields." -// CHECK-NEXT: }, -// CHECK-NEXT: { -// CHECK-NEXT: "TextComment": "" // CHECK-NEXT: } // CHECK: "DocumentationFileName": "_ZTV7MyClass", // CHECK: "Enums": [ @@ -124,8 +121,6 @@ protected: // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: ], -// COM: FIXME: FullName is not emitted correctly. -// CHECK-NEXT: "FullName": "", // CHECK-NEXT: "HasEnums": true, // CHECK-NEXT: "HasPublicFunctions": true, // CHECK-NEXT: "HasPublicMembers": true, diff --git a/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp b/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp index 1a73a0d..5b15a88 100644 --- a/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp +++ b/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/index.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json template<typename T> concept Incrementable = requires (T a) { a++; diff --git a/clang-tools-extra/test/clang-doc/json/concept.cpp b/clang-tools-extra/test/clang-doc/json/concept.cpp index e96ec14..5d8c47e 100644 --- a/clang-tools-extra/test/clang-doc/json/concept.cpp +++ b/clang-tools-extra/test/clang-doc/json/concept.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/index.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json // Requires that T suports post and pre-incrementing. template<typename T> diff --git a/clang-tools-extra/test/clang-doc/json/function-requires.cpp b/clang-tools-extra/test/clang-doc/json/function-requires.cpp index 9427146..8ba6adc 100644 --- a/clang-tools-extra/test/clang-doc/json/function-requires.cpp +++ b/clang-tools-extra/test/clang-doc/json/function-requires.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/index.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json template<typename T> concept Incrementable = requires(T x) { diff --git a/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp b/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp index faaccb7..6630d9e 100644 --- a/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp +++ b/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/index.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json static void myFunction() {} diff --git a/clang-tools-extra/test/clang-doc/json/method-template.cpp b/clang-tools-extra/test/clang-doc/json/method-template.cpp index 87977f8..f4885d9 100644 --- a/clang-tools-extra/test/clang-doc/json/method-template.cpp +++ b/clang-tools-extra/test/clang-doc/json/method-template.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV7MyClass.json struct MyClass { template<class T> T methodTemplate(T param) { diff --git a/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp b/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp index 04fcfc1..6926998 100644 --- a/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp +++ b/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp @@ -1,7 +1,7 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/foo_tools.json --check-prefix=CHECK-FOO -// RUN: FileCheck %s < %t/json/bar_tools.json --check-prefix=CHECK-BAR +// RUN: FileCheck %s < %t/json/foo/tools/index.json --check-prefix=CHECK-FOO +// RUN: FileCheck %s < %t/json/bar/tools/index.json --check-prefix=CHECK-BAR namespace foo { namespace tools { diff --git a/clang-tools-extra/test/clang-doc/json/namespace.cpp b/clang-tools-extra/test/clang-doc/json/namespace.cpp index dcf8323..dd7a9af 100644 --- a/clang-tools-extra/test/clang-doc/json/namespace.cpp +++ b/clang-tools-extra/test/clang-doc/json/namespace.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/index.json +// RUN: FileCheck %s < %t/json/GlobalNamespace/index.json class MyClass {}; diff --git a/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp b/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp index cf19e1e..5baca7f 100644 --- a/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp +++ b/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp @@ -1,7 +1,7 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --output=%t --format=json --executor=standalone %s -// RUN: FileCheck %s < %t/json/nested.json --check-prefix=NESTED -// RUN: FileCheck %s < %t/json/nested_inner.json --check-prefix=INNER +// RUN: FileCheck %s < %t/json/nested/index.json --check-prefix=NESTED +// RUN: FileCheck %s < %t/json/nested/inner/index.json --check-prefix=INNER namespace nested { int Global; diff --git a/clang-tools-extra/test/clang-doc/long-name.cpp b/clang-tools-extra/test/clang-doc/long-name.cpp index e29c468..e4a5e29 100644 --- a/clang-tools-extra/test/clang-doc/long-name.cpp +++ b/clang-tools-extra/test/clang-doc/long-name.cpp @@ -1,9 +1,9 @@ // FIXME: This test seems to break on windows, so disable it for now. // UNSUPPORTED: system-windows // RUN: rm -rf %t && mkdir -p %t -// RUN: clang-doc --output=%t --format=mustache --executor=standalone %s -// RUN: ls %t/json | FileCheck %s -check-prefix=CHECK-JSON -// RUN: ls %t/html | FileCheck %s -check-prefix=CHECK-HTML +// RUN: clang-doc --output=%t --format=html --executor=standalone %s +// RUN: ls %t/json/GlobalNamespace | FileCheck %s -check-prefix=CHECK-JSON +// RUN: ls %t/html/GlobalNamespace | FileCheck %s -check-prefix=CHECK-HTML struct ThisStructHasANameThatResultsInAMangledNameThatIsExactly250CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheLengthIsTooLongThenClangDocWillCrashAnd12 {}; diff --git a/clang-tools-extra/test/clang-doc/mustache-index.cpp b/clang-tools-extra/test/clang-doc/mustache-index.cpp index f9aad19..0aa6e21 100644 --- a/clang-tools-extra/test/clang-doc/mustache-index.cpp +++ b/clang-tools-extra/test/clang-doc/mustache-index.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t -// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s -// RUN: FileCheck %s < %t/html/index.html +// RUN: clang-doc --format=html --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html enum Color { RED, @@ -13,49 +13,47 @@ class Foo; // CHECK: <li class="sidebar-section"> // CHECK-NEXT: <a class="sidebar-item" href="#Enums">Enums</a> // CHECK-NEXT: </li> -// CHECK-NEXT: <ul> -// CHECK-NEXT: <li class="sidebar-item-container"> -// CHECK-NEXT: <a class="sidebar-item" href="#{{[0-9A-F]*}}">Color</a> -// CHECK-NEXT: </li> -// CHECK-NEXT: </ul> +// CHECK-NEXT: <li> +// CHECK-NEXT: <ul> +// CHECK-NEXT: <li class="sidebar-item-container"> +// CHECK-NEXT: <a class="sidebar-item" href="#{{[0-9A-F]*}}">Color</a> +// CHECK-NEXT: </li> +// CHECK-NEXT: </ul> // CHECK: <li class="sidebar-section"> // CHECK-NEXT: <a class="sidebar-item" href="#Classes">Inner Classes</a> // CHECK-NEXT: </li> -// CHECK-NEXT: <ul> -// CHECK-NEXT: <li class="sidebar-item-container"> -// CHECK-NEXT: <a class="sidebar-item" href="#{{[0-9A-F]*}}">Foo</a> -// CHECK-NEXT: </li> -// CHECK-NEXT: </ul> +// CHECK-NEXT: <li> +// CHECK-NEXT: <ul> +// CHECK-NEXT: <li class="sidebar-item-container"> +// CHECK-NEXT: <a class="sidebar-item" href="#{{[0-9A-F]*}}">Foo</a> +// CHECK-NEXT: </li> +// CHECK-NEXT: </ul> // CHECK: <section id="Enums" class="section-container"> // CHECK-NEXT: <h2>Enumerations</h2> // CHECK-NEXT: <div> // CHECK-NEXT: <div id="{{[0-9A-F]*}}" class="delimiter-container"> // CHECK-NEXT: <div> -// CHECK-NEXT: <pre> -// CHECK-NEXT: <code class="language-cpp code-clang-doc"> -// CHECK-NEXT: enum Color -// CHECK-NEXT: </code> -// CHECK-NEXT: </pre> +// CHECK-NEXT: <pre><code class="language-cpp code-clang-doc">enum Color</code></pre> // CHECK-NEXT: </div> // CHECK-NEXT: <table class="table-wrapper"> // CHECK-NEXT: <tbody> -// CHECK-NEXT: <tr> -// CHECK-NEXT: <th>Name</th> -// CHECK-NEXT: <th>Value</th> -// CHECK: </tr> +// CHECK-NEXT: <tr> +// CHECK-NEXT: <th>Name</th> +// CHECK-NEXT: <th>Value</th> +// CHECK-NEXT: </tr> // CHECK-NEXT: <tr> // CHECK-NEXT: <td>RED</td> // CHECK-NEXT: <td>0</td> -// CHECK: </tr> +// CHECK-NEXT: </tr> // CHECK-NEXT: <tr> // CHECK-NEXT: <td>BLUE</td> // CHECK-NEXT: <td>1</td> -// CHECK: </tr> +// CHECK-NEXT: </tr> // CHECK-NEXT: <tr> // CHECK-NEXT: <td>GREEN</td> // CHECK-NEXT: <td>2</td> -// CHECK: </tr> +// CHECK-NEXT: </tr> // CHECK-NEXT: </tbody> // CHECK-NEXT: </table> // CHECK-NEXT: <div> @@ -70,9 +68,7 @@ class Foo; // CHECK-NEXT: <ul class="class-container"> // CHECK-NEXT: <li id="{{[0-9A-F]*}}" style="max-height: 40px;"> // CHECK-NEXT: <a href="_ZTV3Foo.html"> -// CHECK-NEXT: <pre> -// CHECK-NEXT: <code class="language-cpp code-clang-doc">class Foo</code> -// CHECK-NEXT: </pre> +// CHECK-NEXT: <pre><code class="language-cpp code-clang-doc">class Foo</code></pre> // CHECK-NEXT: </a> // CHECK-NEXT: </li> // CHECK-NEXT: </ul> diff --git a/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp b/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp index a73a5ab..add8a22 100644 --- a/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp +++ b/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp @@ -1,6 +1,7 @@ // RUN: rm -rf %t && mkdir -p %t -// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s -// RUN: FileCheck %s < %t/html/MyNamespace.html +// RUN: clang-doc --format=html --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/html/MyNamespace/index.html +// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html --check-prefix=CHECK-GLOBAL namespace MyNamespace { class Foo; @@ -9,9 +10,22 @@ namespace MyNamespace { // CHECK: <ul class="class-container"> // CHECK-NEXT: <li id="{{[0-9A-F]*}}" style="max-height: 40px;"> // CHECK-NEXT: <a href="_ZTVN11MyNamespace3FooE.html"> -// CHECK-NEXT: <pre> -// CHECK-NEXT: <code class="language-cpp code-clang-doc">class Foo</code> -// CHECK-NEXT: </pre> +// CHECK-NEXT: <pre><code class="language-cpp code-clang-doc">class Foo</code></pre> // CHECK-NEXT: </a> // CHECK-NEXT: </li> // CHECK-NEXT: </ul> + +// COM: Check that the empty global namespace doesn't contain tag mismatches. +// CHECK-GLOBAL: <main> +// CHECK-GLOBAL-NEXT: <div class="container"> +// CHECK-GLOBAL-NEXT: <div class="sidebar"> +// CHECK-GLOBAL-NEXT: <h2> </h2> +// CHECK-GLOBAL-NEXT: <ul> +// CHECK-GLOBAL-NEXT: </ul> +// CHECK-GLOBAL-NEXT: </div> +// CHECK-GLOBAL-NEXT: <div class="resizer" id="resizer"></div> +// CHECK-GLOBAL-NEXT: <div class="content"> +// CHECK-GLOBAL-EMPTY: +// CHECK-GLOBAL-NEXT: </div> +// CHECK-GLOBAL-NEXT: </div> +// CHECK-GLOBAL-NEXT: </main> diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp b/clang-tools-extra/test/clang-doc/namespace.cpp index 4fa11c7..029f997 100644 --- a/clang-tools-extra/test/clang-doc/namespace.cpp +++ b/clang-tools-extra/test/clang-doc/namespace.cpp @@ -1,23 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: clang-doc --format=html --output=%t --executor=standalone %s // RUN: clang-doc --format=md --output=%t --executor=standalone %s -// RUN: FileCheck %s < %t/index_json.js -check-prefix=JSON-INDEX -// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS-LINE -// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS -// RUN: FileCheck %s < %t/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX-LINE -// RUN: FileCheck %s < %t/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX -// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.html -check-prefix=HTML-ANOTHER-CLASS-LINE -// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.html -check-prefix=HTML-ANOTHER-CLASS -// RUN: FileCheck %s < %t/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX-LINE -// RUN: FileCheck %s < %t/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX -// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html -check-prefix=HTML-NESTED-CLASS-LINE -// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html -check-prefix=HTML-NESTED-CLASS -// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX-LINE -// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX -// RUN: FileCheck %s < %t/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX-LINE -// RUN: FileCheck %s < %t/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX -// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.html -check-prefix=HTML-PRIMARY-CLASS-LINE -// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.html -check-prefix=HTML-PRIMARY-CLASS // RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS-LINE // RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS // RUN: FileCheck %s < %t/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX-LINE @@ -34,23 +17,42 @@ // RUN: FileCheck %s < %t/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX // RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS-LINE // RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS -// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL-INDEX +// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL-INDEX // RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX // RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES // RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX +// RUN: FileCheck %s < %t/html/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.html -check-prefix=HTML-ANON-CLASS-LINE +// RUN: FileCheck %s < %t/html/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.html -check-prefix=HTML-ANON-CLASS +// RUN: FileCheck %s < %t/html/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX-LINE +// RUN: FileCheck %s < %t/html/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX +// RUN: FileCheck %s < %t/html/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html -check-prefix=HTML-ANOTHER-CLASS-LINE +// RUN: FileCheck %s < %t/html/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html -check-prefix=HTML-ANOTHER-CLASS +// RUN: FileCheck %s < %t/html/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX-LINE +// RUN: FileCheck %s < %t/html/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX +// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html -check-prefix=HTML-NESTED-CLASS-LINE +// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html -check-prefix=HTML-NESTED-CLASS +// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX-LINE +// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX +// RUN: FileCheck %s < %t/html/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX-LINE +// RUN: FileCheck %s < %t/html/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX +// RUN: FileCheck %s < %t/html/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html -check-prefix=HTML-PRIMARY-CLASS-LINE +// RUN: FileCheck %s < %t/html/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html -check-prefix=HTML-PRIMARY-CLASS + +// COM: FIXME: Add global functions to the namespace template +// COM: FIXME: Add namespaces to the namespace template // Anonymous Namespace namespace { void anonFunction() {} // MD-ANON-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]* -// HTML-ANON-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> +// HTML-ANON-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> class AnonClass {}; // MD-ANON-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]* // HTML-ANON-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> // MD-ANON-CLASS: # class AnonClass -// HTML-ANON-CLASS: <h1>class AnonClass</h1> +// HTML-ANON-CLASS: <h1 class="hero__title-large">class AnonClass</h1> } // namespace // MD-ANON-INDEX: # namespace @nonymous_namespace @@ -61,20 +63,24 @@ class AnonClass {}; // MD-ANON-INDEX: ### anonFunction // MD-ANON-INDEX: *void anonFunction()* -// HTML-ANON-INDEX: <h1>namespace @nonymous_namespace</h1> -// HTML-ANON-INDEX: <p> Anonymous Namespace</p> -// HTML-ANON-INDEX: <h2 id="Records">Records</h2> -// HTML-ANON-INDEX: <a href="AnonClass.html">AnonClass</a> -// HTML-ANON-INDEX: <h2 id="Functions">Functions</h2> -// HTML-ANON-INDEX: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3> -// HTML-ANON-INDEX: <p>void anonFunction()</p> +// HTML-ANON-INDEX: <h2> @nonymous_namespace</h2> +// HTML-ANON-INDEX: <h2>Inner Classes</h2> +// HTML-ANON-INDEX: <ul class="class-container"> +// HTML-ANON-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;"> +// HTML-ANON-INDEX: <a href="_ZTVN12_GLOBAL__N_19AnonClassE.html"> +// HTML-ANON-INDEX: <pre><code class="language-cpp code-clang-doc">class AnonClass</code></pre> +// HTML-ANON-INDEX: </a> +// HTML-ANON-INDEX: </li> +// HTML-ANON-INDEX-NOT: <h2 id="Functions">Functions</h2> +// HTML-ANON-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3> +// HTML-ANON-INDEX-NOT: <p>void anonFunction()</p> // Primary Namespace namespace PrimaryNamespace { // Function in PrimaryNamespace void functionInPrimaryNamespace() {} // MD-PRIMARY-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]* -// HTML-PRIMARY-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> +// HTML-PRIMARY-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> // Class in PrimaryNamespace class ClassInPrimaryNamespace {}; @@ -84,15 +90,14 @@ class ClassInPrimaryNamespace {}; // MD-PRIMARY-CLASS: # class ClassInPrimaryNamespace // MD-PRIMARY-CLASS: Class in PrimaryNamespace -// HTML-PRIMARY-CLASS: <h1>class ClassInPrimaryNamespace</h1> -// HTML-PRIMARY-CLASS: <p> Class in PrimaryNamespace</p> +// HTML-PRIMARY-CLASS: <h1 class="hero__title-large">class ClassInPrimaryNamespace</h1> // Nested namespace namespace NestedNamespace { // Function in NestedNamespace void functionInNestedNamespace() {} // MD-NESTED-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]* -// HTML-NESTED-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> +// HTML-NESTED-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> // Class in NestedNamespace class ClassInNestedNamespace {}; @@ -102,8 +107,7 @@ class ClassInNestedNamespace {}; // MD-NESTED-CLASS: # class ClassInNestedNamespace // MD-NESTED-CLASS: Class in NestedNamespace -// HTML-NESTED-CLASS: <h1>class ClassInNestedNamespace</h1> -// HTML-NESTED-CLASS: <p> Class in NestedNamespace</p> +// HTML-NESTED-CLASS: <h1 class="hero__title-large">class ClassInNestedNamespace</h1> } // namespace NestedNamespace // MD-NESTED-INDEX: # namespace NestedNamespace @@ -115,14 +119,19 @@ class ClassInNestedNamespace {}; // MD-NESTED-INDEX: *void functionInNestedNamespace()* // MD-NESTED-INDEX: Function in NestedNamespace -// HTML-NESTED-INDEX: <h1>namespace NestedNamespace</h1> -// HTML-NESTED-INDEX: <p> Nested namespace</p> -// HTML-NESTED-INDEX: <h2 id="Records">Records</h2> -// HTML-NESTED-INDEX: <a href="ClassInNestedNamespace.html">ClassInNestedNamespace</a> -// HTML-NESTED-INDEX: <h2 id="Functions">Functions</h2> -// HTML-NESTED-INDEX: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3> -// HTML-NESTED-INDEX: <p>void functionInNestedNamespace()</p> -// HTML-NESTED-INDEX: <p> Function in NestedNamespace</p> +// HTML-NESTED-INDEX: <h2> NestedNamespace</h2> +// HTML-NESTED-INDEX: <h2>Inner Classes</h2> +// HTML-NESTED-INDEX: <ul class="class-container"> +// HTML-NESTED-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;"> +// HTML-NESTED-INDEX: <a href="_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html"> +// HTML-NESTED-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInNestedNamespace</code></pre> +// HTML-NESTED-INDEX: </a> +// HTML-NESTED-INDEX: </li> +// HTML-NESTED-INDEX: </ul> +// HTML-NESTED-INDEX-NOT: <h2 id="Functions">Functions</h2> +// HTML-NESTED-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3> +// HTML-NESTED-INDEX-NOT: <p>void functionInNestedNamespace()</p> +// HTML-NESTED-INDEX-NOT: <p> Function in NestedNamespace</p> } // namespace PrimaryNamespace // MD-PRIMARY-INDEX: # namespace PrimaryNamespace @@ -136,23 +145,28 @@ class ClassInNestedNamespace {}; // MD-PRIMARY-INDEX: *void functionInPrimaryNamespace()* // MD-PRIMARY-INDEX: Function in PrimaryNamespace -// HTML-PRIMARY-INDEX: <h1>namespace PrimaryNamespace</h1> -// HTML-PRIMARY-INDEX: <p> Primary Namespace</p> -// HTML-PRIMARY-INDEX: <h2 id="Namespaces">Namespaces</h2> -// HTML-PRIMARY-INDEX: <a href="NestedNamespace{{[\/]}}index.html">NestedNamespace</a> -// HTML-PRIMARY-INDEX: <h2 id="Records">Records</h2> -// HTML-PRIMARY-INDEX: <a href="ClassInPrimaryNamespace.html">ClassInPrimaryNamespace</a> -// HTML-PRIMARY-INDEX: <h2 id="Functions">Functions</h2> -// HTML-PRIMARY-INDEX: <h3 id="{{([0-9A-F]{40})}}">functionInPrimaryNamespace</h3> -// HTML-PRIMARY-INDEX: <p>void functionInPrimaryNamespace()</p> -// HTML-PRIMARY-INDEX: <p> Function in PrimaryNamespace</p> +// HTML-PRIMARY-INDEX: <h2> PrimaryNamespace</h2> +// HTML-PRIMARY-INDEX-NOT: <h2 id="Namespaces">Namespaces</h2> +// HTML-PRIMARY-INDEX-NOT: <a href="NestedNamespace{{[\/]}}index.html">NestedNamespace</a> +// HTML-PRIMARY-INDEX <h2>Inner Classes</h2> +// HTML-PRIMARY-INDEX <ul class="class-container"> +// HTML-PRIMARY-INDEX <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;"> +// HTML-PRIMARY-INDEX <a href="_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html"> +// HTML-PRIMARY-INDEX <pre><code class="language-cpp code-clang-doc">class ClassInPrimaryNamespace</code></pre> +// HTML-PRIMARY-INDEX </a> +// HTML-PRIMARY-INDEX </li> +// HTML-PRIMARY-INDEX </ul> +// HTML-PRIMARY-INDEX-NOT: <h2 id="Functions">Functions</h2> +// HTML-PRIMARY-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInPrimaryNamespace</h3> +// HTML-PRIMARY-INDEX-NOT: <p>void functionInPrimaryNamespace()</p> +// HTML-PRIMARY-INDEX-NOT: <p> Function in PrimaryNamespace</p> // AnotherNamespace namespace AnotherNamespace { // Function in AnotherNamespace void functionInAnotherNamespace() {} // MD-ANOTHER-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]* -// HTML-ANOTHER-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> +// HTML-ANOTHER-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> // Class in AnotherNamespace class ClassInAnotherNamespace {}; @@ -162,8 +176,7 @@ class ClassInAnotherNamespace {}; // MD-ANOTHER-CLASS: # class ClassInAnotherNamespace // MD-ANOTHER-CLASS: Class in AnotherNamespace -// HTML-ANOTHER-CLASS: <h1>class ClassInAnotherNamespace</h1> -// HTML-ANOTHER-CLASS: <p> Class in AnotherNamespace</p> +// HTML-ANOTHER-CLASS: <h1 class="hero__title-large">class ClassInAnotherNamespace</h1> } // namespace AnotherNamespace @@ -176,99 +189,27 @@ class ClassInAnotherNamespace {}; // MD-ANOTHER-INDEX: *void functionInAnotherNamespace()* // MD-ANOTHER-INDEX: Function in AnotherNamespace -// HTML-ANOTHER-INDEX: <h1>namespace AnotherNamespace</h1> -// HTML-ANOTHER-INDEX: <p> AnotherNamespace</p> -// HTML-ANOTHER-INDEX: <h2 id="Records">Records</h2> -// HTML-ANOTHER-INDEX: <a href="ClassInAnotherNamespace.html">ClassInAnotherNamespace</a> -// HTML-ANOTHER-INDEX: <h2 id="Functions">Functions</h2> -// HTML-ANOTHER-INDEX: <h3 id="{{([0-9A-F]{40})}}">functionInAnotherNamespace</h3> -// HTML-ANOTHER-INDEX: <p>void functionInAnotherNamespace()</p> -// HTML-ANOTHER-INDEX: <p> Function in AnotherNamespace</p> - -// JSON-INDEX: async function LoadIndex() { -// JSON-INDEX-NEXT: return{ -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "", -// JSON-INDEX-NEXT: "RefType": "default", -// JSON-INDEX-NEXT: "Path": "", -// JSON-INDEX-NEXT: "Children": [ -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "@nonymous_namespace", -// JSON-INDEX-NEXT: "RefType": "namespace", -// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", -// JSON-INDEX-NEXT: "Children": [ -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "AnonClass", -// JSON-INDEX-NEXT: "RefType": "record", -// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", -// JSON-INDEX-NEXT: "Children": [] -// JSON-INDEX-NEXT: } -// JSON-INDEX-NEXT: ] -// JSON-INDEX-NEXT: }, -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "AnotherNamespace", -// JSON-INDEX-NEXT: "RefType": "namespace", -// JSON-INDEX-NEXT: "Path": "AnotherNamespace", -// JSON-INDEX-NEXT: "Children": [ -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "ClassInAnotherNamespace", -// JSON-INDEX-NEXT: "RefType": "record", -// JSON-INDEX-NEXT: "Path": "AnotherNamespace", -// JSON-INDEX-NEXT: "Children": [] -// JSON-INDEX-NEXT: } -// JSON-INDEX-NEXT: ] -// JSON-INDEX-NEXT: }, -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "GlobalNamespace", -// JSON-INDEX-NEXT: "RefType": "namespace", -// JSON-INDEX-NEXT: "Path": "GlobalNamespace", -// JSON-INDEX-NEXT: "Children": [] -// JSON-INDEX-NEXT: }, -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "PrimaryNamespace", -// JSON-INDEX-NEXT: "RefType": "namespace", -// JSON-INDEX-NEXT: "Path": "PrimaryNamespace", -// JSON-INDEX-NEXT: "Children": [ -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "ClassInPrimaryNamespace", -// JSON-INDEX-NEXT: "RefType": "record", -// JSON-INDEX-NEXT: "Path": "PrimaryNamespace", -// JSON-INDEX-NEXT: "Children": [] -// JSON-INDEX-NEXT: }, -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "NestedNamespace", -// JSON-INDEX-NEXT: "RefType": "namespace", -// JSON-INDEX-NEXT: "Path": "PrimaryNamespace{{[\/]+}}NestedNamespace", -// JSON-INDEX-NEXT: "Children": [ -// JSON-INDEX-NEXT: { -// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", -// JSON-INDEX-NEXT: "Name": "ClassInNestedNamespace", -// JSON-INDEX-NEXT: "RefType": "record", -// JSON-INDEX-NEXT: "Path": "PrimaryNamespace{{[\/]+}}NestedNamespace", -// JSON-INDEX-NEXT: "Children": [] -// JSON-INDEX-NEXT: } -// JSON-INDEX-NEXT: ] -// JSON-INDEX-NEXT: } -// JSON-INDEX-NEXT: ] -// JSON-INDEX-NEXT: } -// JSON-INDEX-NEXT: ] -// JSON-INDEX-NEXT: }; -// JSON-INDEX-NEXT: } - -// HTML-GLOBAL-INDEX: <div id="main-content" class="col-xs-12 col-sm-9 col-md-8 main-content"> -// HTML-GLOBAL-INDEX: <h1>Global Namespace</h1> -// HTML-GLOBAL-INDEX: <h2 id="Namespaces">Namespaces</h2> -// HTML-GLOBAL-INDEX: <li>@nonymous_namespace</li> -// HTML-GLOBAL-INDEX: <li>AnotherNamespace</li> -// HTML-GLOBAL-INDEX: <li>PrimaryNamespace</li> +// HTML-ANOTHER-INDEX: <h2> AnotherNamespace</h2> +// HTML-ANOTHER-INDEX: <h2>Inner Classes</h2> +// HTML-ANOTHER-INDEX: <ul class="class-container"> +// HTML-ANOTHER-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;"> +// HTML-ANOTHER-INDEX: <a href="_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html"> +// HTML-ANOTHER-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInAnotherNamespace</code></pre> +// HTML-ANOTHER-INDEX: </a> +// HTML-ANOTHER-INDEX: </li> +// HTML-ANOTHER-INDEX: </ul> +// HTML-ANOTHER-INDEX-NOT: <h2 id="Functions">Functions</h2> +// HTML-ANOTHER-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInAnotherNamespace</h3> +// HTML-ANOTHER-INDEX-NOT: <p>void functionInAnotherNamespace()</p> +// HTML-ANOTHER-INDEX-NOT: <p> Function in AnotherNamespace</p> + +// COM: FIXME: Add namespaces to namespace template +// HTML-GLOBAL-INDEX-NOT: <div id="main-content" class="col-xs-12 col-sm-9 col-md-8 main-content"> +// HTML-GLOBAL-INDEX-NOT: <h1>Global Namespace</h1> +// HTML-GLOBAL-INDEX-NOT: <h2 id="Namespaces">Namespaces</h2> +// HTML-GLOBAL-INDEX-NOT: <li>@nonymous_namespace</li> +// HTML-GLOBAL-INDEX-NOT: <li>AnotherNamespace</li> +// HTML-GLOBAL-INDEX-NOT: <li>PrimaryNamespace</li> // MD-GLOBAL-INDEX: # Global Namespace // MD-GLOBAL-INDEX: ## Namespaces diff --git a/clang-tools-extra/test/clang-doc/test-path-abs.cpp b/clang-tools-extra/test/clang-doc/test-path-abs.cpp deleted file mode 100644 index 8875a3a..0000000 --- a/clang-tools-extra/test/clang-doc/test-path-abs.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: rm -rf %t && mkdir -p %t -// RUN: clang-doc --format=html --executor=standalone %s --output=%t --base base_dir -// RUN: FileCheck %s -input-file=%t/index_json.js -check-prefix=JSON-INDEX - -// JSON-INDEX: var RootPath = "{{.*}}test-path-abs.cpp.tmp"; -// JSON-INDEX-NEXT: var Base = "base_dir"; - diff --git a/clang-tools-extra/test/clang-tidy/.clang-tidy b/clang-tools-extra/test/clang-tidy/.clang-tidy new file mode 100644 index 0000000..612bd0e --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*' diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py index 183b33f..b173ecf 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -398,6 +398,8 @@ def parse_arguments() -> Tuple[argparse.Namespace, List[str]]: def main() -> None: + sys.stdout.reconfigure(encoding="utf-8") + sys.stderr.reconfigure(encoding="utf-8") args, extra_args = parse_arguments() abbreviated_stds = args.std diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-simulation.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-simulation.h index b6977cd..0870f60 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-simulation.h +++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-simulation.h @@ -59,7 +59,7 @@ struct X {}; } // namespace std // Template specializations that are in a system-header file. -// The purpose is to test cert-dcl58-cpp (no warnings here). +// The purpose is to test bugprone-std-namespace-modification (no warnings here). namespace std { template <> void swap<short>(short &, short &){}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/oop58-cpp.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-mutates-argument.cpp index 223248c..9fdbb7a 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/oop58-cpp.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-mutates-argument.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s cert-oop58-cpp %t +// RUN: %check_clang_tidy %s bugprone-copy-constructor-mutates-argument %t // Example test cases from CERT rule // https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP58-CPP.+Copy+operations+must+not+mutate+the+source+object diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/default-operator-new-on-overaligned-type-cpp17.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/default-operator-new-on-overaligned-type-cpp17.cpp new file mode 100644 index 0000000..b05108c --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/default-operator-new-on-overaligned-type-cpp17.cpp @@ -0,0 +1,12 @@ +// RUN: %check_clang_tidy %s -std=c++14 bugprone-default-operator-new-on-overaligned-type %t +// RUN: clang-tidy -checks='-*,bugprone-default-operator-new-on-overaligned-type' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation +// RUN: clang-tidy -checks='-*,bugprone-default-operator-new-on-overaligned-type' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation + +struct alignas(128) Vector { + char Elems[128]; +}; + +void f() { + auto *V1 = new Vector; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [bugprone-default-operator-new-on-overaligned-type] + auto *V1_Arr = new Vector[2]; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [bugprone-default-operator-new-on-overaligned-type] +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/default-operator-new-on-overaligned-type.cpp index e0300e3..379d8a2 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/default-operator-new-on-overaligned-type.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t +// RUN: %check_clang_tidy %s -std=c++14 bugprone-default-operator-new-on-overaligned-type %t namespace std { typedef __typeof(sizeof(int)) size_t; @@ -30,10 +30,10 @@ struct alignas(8) Vector4 { void f() { auto *V1 = new Vector1; - // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [cert-mem57-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [bugprone-default-operator-new-on-overaligned-type] auto *V2 = new Vector2; auto *V3 = new Vector3; auto *V4 = new Vector4; auto *V1_Arr = new Vector1[2]; - // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [cert-mem57-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [bugprone-default-operator-new-on-overaligned-type] } diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-copy-constructor-throws.cpp index 34ca837..7e2d586 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-copy-constructor-throws.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11,c++14 %s cert-err60-cpp %t -- -- -fcxx-exceptions +// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-copy-constructor-throws %t -- -- -fcxx-exceptions // FIXME: Split off parts of this test that rely on dynamic exception // specifications, and run this test in all language modes. // FIXME: Fix the checker to work in C++17 or later mode. @@ -92,7 +92,7 @@ void f() { throw U(); // ok throw V(); // ok throw W(); // match, noexcept(false) - // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible [bugprone-exception-copy-constructor-throws] throw X(); // match, no noexcept clause, nontrivial // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible throw Y(); // ok diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-options.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-options.cpp new file mode 100644 index 0000000..48c9bac --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-options.cpp @@ -0,0 +1,47 @@ +// RUN: %check_clang_tidy -std=c++11-or-later %s bugprone-exception-escape %t -- \ +// RUN: -config="{CheckOptions: { \ +// RUN: bugprone-exception-escape.CheckDestructors: false, \ +// RUN: bugprone-exception-escape.CheckMoveMemberFunctions: false, \ +// RUN: bugprone-exception-escape.CheckMain: false, \ +// RUN: bugprone-exception-escape.CheckedSwapFunctions: '', \ +// RUN: bugprone-exception-escape.CheckNothrowFunctions: false \ +// RUN: }}" \ +// RUN: -- -fexceptions + +// CHECK-MESSAGES-NOT: warning: + +struct destructor { + ~destructor() { + throw 1; + } +}; + +struct move { + move(move&&) { throw 42; } + move& operator=(move&&) { throw 42; } +}; + +void swap(int&, int&) { + throw 1; +} + +void iter_swap(int&, int&) { + throw 1; +} + +void iter_move(int&) { + throw 1; +} + +void nothrow_func() throw() { + throw 1; +} + +void noexcept_func() noexcept { + throw 1; +} + +int main() { + throw 1; + return 0; +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp index a52bbe2..140c93f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp @@ -948,7 +948,7 @@ const auto throw_in_noexcept_lambda = [] () noexcept { throw 42; }; // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: an exception may be thrown in function 'operator()' which should not throw exceptions // CHECK-MESSAGES: :[[@LINE-2]]:56: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here -void thrower() { +int thrower() { throw 42; } @@ -956,3 +956,54 @@ const auto indirect_throw_in_noexcept_lambda = [] () noexcept { thrower(); }; // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: an exception may be thrown in function 'operator()' which should not throw exceptions // CHECK-MESSAGES: :[[@LINE-5]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here // CHECK-MESSAGES: :[[@LINE-3]]:65: note: frame #1: function 'operator()' calls function 'thrower' here + +int f(int); +void throw_in_function_arg() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_function_arg' which should not throw exceptions + f(false ? 0 : throw 1); +} +// CHECK-MESSAGES: :[[@LINE-2]]:17: note: frame #0: unhandled exception of type 'int' may be thrown in function 'throw_in_function_arg' here + +int g(int, int, int); +void throw_in_last_function_arg() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_last_function_arg' which should not throw exceptions + g(42, 67, false ? 0 : throw 1); +} +// CHECK-MESSAGES: :[[@LINE-2]]:25: note: frame #0: unhandled exception of type 'int' may be thrown in function 'throw_in_last_function_arg' here + +void indirect_throw_in_function_arg() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_throw_in_function_arg' which should not throw exceptions + f(thrower()); +} +// CHECK-MESSAGES: :[[@LINE-26]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here +// CHECK-MESSAGES: :[[@LINE-3]]:5: note: frame #1: function 'indirect_throw_in_function_arg' calls function 'thrower' here + +void indirect_throw_from_lambda_in_function_arg() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_throw_from_lambda_in_function_arg' which should not throw exceptions + f([] { throw 1; return 0; }()); +} +// CHECK-MESSAGES: :[[@LINE-2]]:10: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here +// CHECK-MESSAGES: :[[@LINE-3]]:30: note: frame #1: function 'indirect_throw_from_lambda_in_function_arg' calls function 'operator()' here + +struct S { + S(int) noexcept {} +}; + +void throw_in_constructor_arg() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_constructor_arg' which should not throw exceptions + S s(false ? 0 : throw 1); +} +// CHECK-MESSAGES: :[[@LINE-2]]:19: note: frame #0: unhandled exception of type 'int' may be thrown in function 'throw_in_constructor_arg' here + +void indirect_throw_in_constructor_arg() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_throw_in_constructor_arg' which should not throw exceptions + S s = thrower(); +} +// CHECK-MESSAGES: :[[@LINE-50]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here +// CHECK-MESSAGES: :[[@LINE-3]]:9: note: frame #1: function 'indirect_throw_in_constructor_arg' calls function 'thrower' here + +void weird_throw_in_call_subexpression() noexcept { +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'weird_throw_in_call_subexpression' which should not throw exceptions + (false ? []{} : throw 1)(); +} +// CHECK-MESSAGES: :[[@LINE-2]]:19: note: frame #0: unhandled exception of type 'int' may be thrown in function 'weird_throw_in_call_subexpression' here diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/flp30-c.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/float-loop-counter.c index b998588..77812f0 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/flp30-c.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/float-loop-counter.c @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s cert-flp30-c %t +// RUN: %check_clang_tidy %s bugprone-float-loop-counter %t float g(void); int c(float); @@ -7,16 +7,16 @@ float f = 1.0f; void match(void) { for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} - // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: loop induction expression should not have floating-point type [cert-flp30-c] + // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: loop induction expression should not have floating-point type [bugprone-float-loop-counter] for (; f > 0; --f) {} - // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: loop induction expression should not have floating-point type [cert-flp30-c] + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: loop induction expression should not have floating-point type [bugprone-float-loop-counter] for (float x = 0.0f; c(x); x = g()) {} - // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: loop induction expression should not have floating-point type [cert-flp30-c] + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: loop induction expression should not have floating-point type [bugprone-float-loop-counter] for (int i=0; i < 10 && f < 2.0f; f++, i++) {} - // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: loop induction expression should not have floating-point type [cert-flp30-c] + // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: loop induction expression should not have floating-point type [bugprone-float-loop-counter] // CHECK-MESSAGES: :5:1: note: floating-point type loop induction variable } diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/msc32-c.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/random-generator-seed.c index 0a1d79b..7f2a068 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/msc32-c.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/random-generator-seed.c @@ -1,4 +1,5 @@ -// RUN: %check_clang_tidy %s cert-msc32-c %t -- -config="{CheckOptions: {cert-msc32-c.DisallowedSeedTypes: 'some_type,time_t'}}" -- -std=c99 +// RUN: %check_clang_tidy %s bugprone-random-generator-seed %t -- \ +// RUN: -config="{CheckOptions: {bugprone-random-generator-seed.DisallowedSeedTypes: 'some_type,time_t'}}" void srand(int seed); typedef int time_t; @@ -6,15 +7,15 @@ time_t time(time_t *t); void f(void) { srand(1); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc32-c] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] const int a = 1; srand(a); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc32-c] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] time_t t; srand(time(&t)); // Disallowed seed type - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc32-c] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] } void g(void) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/msc51-cpp.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/random-generator-seed.cpp index 637ba58..c8818d6 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/msc51-cpp.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/random-generator-seed.cpp @@ -1,5 +1,5 @@ -// RUN: %check_clang_tidy %s cert-msc51-cpp %t -- \ -// RUN: -config="{CheckOptions: {cert-msc51-cpp.DisallowedSeedTypes: 'some_type,time_t'}}" +// RUN: %check_clang_tidy %s bugprone-random-generator-seed %t -- \ +// RUN: -config="{CheckOptions: {bugprone-random-generator-seed.DisallowedSeedTypes: 'some_type,time_t'}}" namespace std { @@ -71,114 +71,114 @@ void f() { time_t t; std::srand(0); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::srand(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::srand(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] // One instantiation for every engine std::default_random_engine engine1; - // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] std::default_random_engine engine2(1); - // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::default_random_engine engine3(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::default_random_engine engine4(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] engine1.seed(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] engine1.seed(1); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine1.seed(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine1.seed(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] std::mt19937 engine5; - // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] std::mt19937 engine6(1); - // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::mt19937 engine7(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::mt19937 engine8(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] engine5.seed(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] engine5.seed(1); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine5.seed(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine5.seed(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24_base engine9; - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24_base engine10(1); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24_base engine11(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24_base engine12(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] engine9.seed(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] engine9.seed(1); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine9.seed(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine9.seed(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24 engine13; - // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24 engine14(1); - // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24 engine15(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::ranlux24 engine16(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] engine13.seed(); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] engine13.seed(1); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine13.seed(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine13.seed(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] std::independent_bits engine17; - // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] std::independent_bits engine18(1); - // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::independent_bits engine19(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::independent_bits engine20(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] engine17.seed(); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] engine17.seed(1); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine17.seed(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine17.seed(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] std::shuffle_order engine21; - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] std::shuffle_order engine22(1); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::shuffle_order engine23(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] std::shuffle_order engine24(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] engine21.seed(); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a default argument will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a default argument will generate a predictable sequence of values [bugprone-random-generator-seed] engine21.seed(1); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine21.seed(seed); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a constant value will generate a predictable sequence of values [bugprone-random-generator-seed] engine21.seed(time(&t)); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [bugprone-random-generator-seed] } struct A { diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/oop57-cpp.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/raw-memory-call-on-non-trivial-type.cpp index e34315f..41a86ff 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/oop57-cpp.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/raw-memory-call-on-non-trivial-type.cpp @@ -1,8 +1,8 @@ -// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \ +// RUN: %check_clang_tidy %s bugprone-raw-memory-call-on-non-trivial-type %t -- \ // RUN: -config='{CheckOptions: \ -// RUN: {cert-oop57-cpp.MemSetNames: mymemset, \ -// RUN: cert-oop57-cpp.MemCpyNames: mymemcpy, \ -// RUN: cert-oop57-cpp.MemCmpNames: mymemcmp}}' \ +// RUN: {bugprone-raw-memory-call-on-non-trivial-type.MemSetNames: mymemset, \ +// RUN: bugprone-raw-memory-call-on-non-trivial-type.MemCpyNames: mymemcpy, \ +// RUN: bugprone-raw-memory-call-on-non-trivial-type.MemCmpNames: mymemcmp}}' \ // RUN: -- void mymemset(void *, unsigned char, decltype(sizeof(int))); diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/std-namespace-modification.cpp index 01964e7..32bcbca 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/std-namespace-modification.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy -std=c++17-or-later %s cert-dcl58-cpp %t -- -- -I %clang_tidy_headers +// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-std-namespace-modification %t -- -- -I %clang_tidy_headers #include "system-header-simulation.h" @@ -15,7 +15,7 @@ namespace A { } namespace posix { -// CHECK-MESSAGES: :[[@LINE+2]]:11: warning: modification of 'posix' namespace can result in undefined behavior [cert-dcl58-cpp] +// CHECK-MESSAGES: :[[@LINE+2]]:11: warning: modification of 'posix' namespace can result in undefined behavior [bugprone-std-namespace-modification] // CHECK-MESSAGES: :[[@LINE-2]]:11: note: 'posix' namespace opened here namespace foo { int foobar; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access-ignore-value.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access-ignore-value.cpp new file mode 100644 index 0000000..f546212 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access-ignore-value.cpp @@ -0,0 +1,25 @@ +// RUN: %check_clang_tidy %s bugprone-unchecked-optional-access %t -- \ +// RUN: -config="{CheckOptions: \ +// RUN: {bugprone-unchecked-optional-access.IgnoreValueCalls: true}}" -- \ +// RUN: -I %S/Inputs/unchecked-optional-access + +#include "absl/types/optional.h" + +struct Foo { + void foo() const {} +}; + +void unchecked_value_access(const absl::optional<int> &opt) { + opt.value(); // no-warning +} + +void unchecked_deref_operator_access(const absl::optional<int> &opt) { + *opt; + // CHECK-MESSAGES: :[[@LINE-1]]:4: warning: unchecked access to optional value +} + +void unchecked_arrow_operator_access(const absl::optional<Foo> &opt) { + opt->foo(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional value +} + diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions-custom.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions-custom.c index 7fd71ec..7eaf015 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions-custom.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions-custom.c @@ -1,5 +1,5 @@ // RUN: %check_clang_tidy -check-suffix=NON-STRICT-REGEX %s bugprone-unsafe-functions %t --\ -// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '::name_match,replacement,is a qualname match;^::prefix_match,,is matched on qualname prefix'}}" +// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: \"::name_match,,>is a qualname match, but with a fully 'custom' message;^::prefix_match,,is matched on qualname prefix\"}}" // RUN: %check_clang_tidy -check-suffix=STRICT-REGEX %s bugprone-unsafe-functions %t --\ // RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '^name_match$,replacement,is matched on function name only;^::prefix_match$,,is a full qualname match'}}" @@ -11,14 +11,14 @@ void prefix_match_regex(); void f1() { name_match(); - // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'name_match' is a qualname match; 'replacement' should be used instead + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'name_match' is a qualname match, but with a fully 'custom' message // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'name_match' is matched on function name only; 'replacement' should be used instead prefix_match(); // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'prefix_match' is matched on qualname prefix; it should not be used // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'prefix_match' is a full qualname match; it should not be used name_match_regex(); - // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'name_match_regex' is a qualname match; 'replacement' should be used instead + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'name_match_regex' is a qualname match, but with a fully 'custom' message // no-warning STRICT-REGEX prefix_match_regex(); diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp index 87dfec4..b2df263 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp @@ -1,5 +1,13 @@ -// RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX11 %s bugprone-use-after-move %t -- -- -fno-delayed-template-parsing -// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-use-after-move %t -- -- -fno-delayed-template-parsing +// RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX11 %s bugprone-use-after-move %t -- \ +// RUN: -config='{CheckOptions: { \ +// RUN: bugprone-use-after-move.InvalidationFunctions: "::Database<>::StaticCloseConnection;Database<>::CloseConnection;FriendCloseConnection" \ +// RUN: }}' -- \ +// RUN: -fno-delayed-template-parsing +// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-use-after-move %t -- \ +// RUN: -config='{CheckOptions: { \ +// RUN: bugprone-use-after-move.InvalidationFunctions: "::Database<>::StaticCloseConnection;Database<>::CloseConnection;FriendCloseConnection" \ +// RUN: }}' -- \ +// RUN: -fno-delayed-template-parsing typedef decltype(nullptr) nullptr_t; @@ -1645,3 +1653,53 @@ void create() { } } // namespace issue82023 + +namespace custom_invalidation +{ + +template<class T = int> +struct Database { + template<class...> + void CloseConnection(T = T()) {} + template<class...> + static void StaticCloseConnection(Database&, T = T()) {} + template<class...> + friend void FriendCloseConnection(Database&, T = T()) {} + void Query(); +}; + +void Run() { + using DB = Database<>; + + DB db1; + db1.CloseConnection(); + db1.Query(); + // CHECK-NOTES: [[@LINE-1]]:3: warning: 'db1' used after it was invalidated + // CHECK-NOTES: [[@LINE-3]]:7: note: invalidation occurred here + + DB db2; + DB::StaticCloseConnection(db2); + db2.Query(); + // CHECK-NOTES: [[@LINE-1]]:3: warning: 'db2' used after it was invalidated + // CHECK-NOTES: [[@LINE-3]]:3: note: invalidation occurred here + + DB db3; + DB().StaticCloseConnection(db3); + db3.Query(); + // CHECK-NOTES: [[@LINE-1]]:3: warning: 'db3' used after it was invalidated + // CHECK-NOTES: [[@LINE-3]]:3: note: invalidation occurred here + + DB db4; + FriendCloseConnection(db4); + db4.Query(); + // CHECK-NOTES: [[@LINE-1]]:3: warning: 'db4' used after it was invalidated + // CHECK-NOTES: [[@LINE-3]]:3: note: invalidation occurred here + + DB db5; + FriendCloseConnection(db5, /*disconnect timeout*/ 5); + db5.Query(); + // CHECK-NOTES: [[@LINE-1]]:3: warning: 'db5' used after it was invalidated + // CHECK-NOTES: [[@LINE-3]]:3: note: invalidation occurred here +} + +} // namespace custom_invalidation diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp b/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp deleted file mode 100644 index 38ffcbd..0000000 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t -// RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation -// RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation - -struct alignas(128) Vector { - char Elems[128]; -}; - -void f() { - auto *V1 = new Vector; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [cert-mem57-cpp] - auto *V1_Arr = new Vector[2]; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [cert-mem57-cpp] -} diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.ignorearrays.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.ignorearrays.cpp index 01859b3..e4cfe67 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.ignorearrays.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.ignorearrays.cpp @@ -14,3 +14,39 @@ struct HasArrayMember { int RawArray[4]; int Number; }; + +namespace std { +template <typename T, int N> +struct array { + T _Elems[N]; + void fill(const T &); +}; +} + +void test_local_std_array() { + std::array<int, 4> a; +} + +struct OnlyArray { + int a[4]; +}; + +void test_local_only_array() { + OnlyArray a; +} + +struct Mixed { + int a[4]; + int b; +}; + +void test_local_mixed() { + Mixed m; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: uninitialized record type: 'm' +} + +void test_std_array_fill() { + std::array<char, 10> someArray; + // CHECK-MESSAGES-NOT: warning: uninitialized record type: 'someArray' + someArray.fill('n'); +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp b/clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp index d53b3fd..c60649f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp @@ -148,3 +148,18 @@ void test_no_crash() { auto foo = []() {}; WithTemplBase<decltype(foo)>(); } + +struct S1 {}; +struct S2 {}; + +struct S3 : S1, S2 {}; + +namespace N { + +struct S1 { int i; }; +struct S2 { int i; }; + +// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance] +struct S3 : S1, S2 {}; + +} // namespace N diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.c b/clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.c deleted file mode 100644 index f0d5339..0000000 --- a/clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.c +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %check_clang_tidy %s google-readability-casting %t -- -- -x c -// The testing script always adds .cpp extension to the input file name, so we -// need to run clang-tidy directly in order to verify handling of .c files: -// RUN: clang-tidy --checks=-*,google-readability-casting %s -- -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:' -// RUN: cp %s %t.main_file.cpp -// RUN: clang-tidy --checks=-*,google-readability-casting -header-filter='.*' %t.main_file.cpp -- -I%S -DTEST_INCLUDE -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:' - -#ifdef TEST_INCLUDE - -#undef TEST_INCLUDE -#include "readability-casting.c" - -#else - -void f(const char *cpc) { - const char *cpc2 = (const char*)cpc; - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting] - // CHECK-FIXES: const char *cpc2 = cpc; - char *pc = (char*)cpc; - typedef const char *Typedef1; - (Typedef1)cpc; -} - -#endif diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-hyphen.cpp b/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-hyphen.cpp new file mode 100644 index 0000000..5701b30 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-hyphen.cpp @@ -0,0 +1,40 @@ +// RUN: %check_clang_tidy %s google-readability-todo %t -- -config="{User: 'some user'}" -- + +// TODOfix this1 +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO +// CHECK-FIXES: // TODO: some user - fix this1 + +// TODO fix this2 +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO +// CHECK-FIXES: // TODO: some user - fix this2 + +// TODO fix this3 +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO +// CHECK-FIXES: // TODO: some user - fix this3 + +// TODO: fix this4 +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO +// CHECK-FIXES: // TODO: some user - fix this4 + +// TODO: bug 12345 - +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing details in TODO + +// TODO: a message without a reference +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO +// CHECK-FIXES: // TODO: some user - a message without a reference + +// TODO(clang)fix this5 + +// TODO: foo - shave yaks +// TODO:foo - no space bewteen semicolon and username +// TODO: foo- no space bewteen username and dash +// TODO: foo - extra spaces between semicolon and username +// TODO: foo - extra spaces between username and dash +// TODO: b/12345 - use a b/ prefix +// TODO: bug 12345 - use a space in username/bug reference +// TODO(foo):shave yaks +// TODO(bar): +// TODO(foo): paint bikeshed +// TODO(b/12345): find the holy grail +// TODO (b/12345): allow spaces before parentheses +// TODO(asdf) allow missing semicolon diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo.cpp b/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-parentheses.cpp index 6b900aa..f97e395 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-parentheses.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s google-readability-todo %t -- -config="{User: 'some user'}" -- +// RUN: %check_clang_tidy %s google-readability-todo %t -- -config="{User: 'some user', CheckOptions: {google-readability-todo.Style: 'Parentheses'}}" -- // TODOfix this1 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO @@ -16,8 +16,22 @@ // CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO // CHECK-FIXES: // TODO(some user): fix this4 +// TODO: bug 12345 - +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing details in TODO + +// TODO: a message without a reference +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO +// CHECK-FIXES: // TODO(some user): a message without a reference + // TODO(clang)fix this5 +// TODO: foo - shave yaks +// TODO:foo - no space bewteen semicolon and username +// TODO: foo- no space bewteen username and dash +// TODO: foo - extra spaces between semicolon and username +// TODO: foo - extra spaces between username and dash +// TODO: b/12345 - use a b/ prefix +// TODO: bug 12345 - use a space in username/bug reference // TODO(foo):shave yaks // TODO(bar): // TODO(foo): paint bikeshed diff --git a/clang-tools-extra/test/clang-tidy/checkers/llvm/use-new-mlir-op-builder.cpp b/clang-tools-extra/test/clang-tidy/checkers/llvm/use-new-mlir-op-builder.cpp index b57eab0..c4a1d8d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/llvm/use-new-mlir-op-builder.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/llvm/use-new-mlir-op-builder.cpp @@ -2,6 +2,7 @@ namespace mlir { class Location {}; +class Value {}; class OpBuilder { public: template <typename OpTy, typename... Args> @@ -28,6 +29,13 @@ struct NamedOp { static NamedOp create(OpBuilder &builder, Location location, const char* name) { return NamedOp(name); } + Value getResult() { return Value(); } +}; +struct OperandOp { + OperandOp(Value val) {} + static OperandOp create(OpBuilder &builder, Location location, Value val) { + return OperandOp(val); + } }; } // namespace mlir @@ -40,6 +48,22 @@ void g(mlir::OpBuilder &b) { b.create<T>(b.getUnknownLoc(), "gaz"); } +class CustomBuilder : public mlir::ImplicitLocOpBuilder { +public: + mlir::NamedOp f(const char *name) { + // CHECK-MESSAGES: :[[@LINE+2]]:12: warning: use 'OpType::create(builder, ...)' + // CHECK-FIXES: return mlir::NamedOp::create(*this, name); + return create<mlir::NamedOp>(name); + } + + mlir::NamedOp g(const char *name) { + using mlir::NamedOp; + // CHECK-MESSAGES: :[[@LINE+2]]:12: warning: use 'OpType::create(builder, ...)' + // CHECK-FIXES: return NamedOp::create(*this, name); + return create<NamedOp>(name); + } +}; + void f() { mlir::OpBuilder builder; // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] @@ -47,15 +71,18 @@ void f() { builder.create<mlir:: ModuleOp>(builder.getUnknownLoc()); using mlir::NamedOp; + using mlir::OperandOp; + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] // CHECK-FIXES: NamedOp::create(builder, builder.getUnknownLoc(), "baz"); builder.create<NamedOp>(builder.getUnknownLoc(), "baz"); - // CHECK-MESSAGES: :[[@LINE+3]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] - // CHECK-FIXES: NamedOp::create(builder, builder.getUnknownLoc(), - // CHECK-FIXES: "caz"); + // CHECK-MESSAGES: :[[@LINE+4]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] + // CHECK-FIXES: NamedOp::create(builder, + // CHECK-FIXES: builder.getUnknownLoc(), + // CHECK-FIXES: "caz"); builder. - create<NamedOp>( + create<NamedOp> ( builder.getUnknownLoc(), "caz"); @@ -66,10 +93,26 @@ void f() { mlir::ImplicitLocOpBuilder ib; // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] - // CHECK-FIXES: mlir::ModuleOp::create(ib); + // CHECK-FIXES: mlir::ModuleOp::create(ib ); ib.create<mlir::ModuleOp>( ); // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] // CHECK-FIXES: mlir::OpBuilder().create<mlir::ModuleOp>(builder.getUnknownLoc()); mlir::OpBuilder().create<mlir::ModuleOp>(builder.getUnknownLoc()); + + auto *p = &builder; + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' + // CHECK-FIXES: NamedOp::create(*p, builder.getUnknownLoc(), "eaz"); + p->create<NamedOp>(builder.getUnknownLoc(), "eaz"); + + CustomBuilder cb; + cb.f("faz"); + cb.g("gaz"); + + // CHECK-FIXES: OperandOp::create(builder, builder.getUnknownLoc(), + // CHECK-FIXES-NEXT: NamedOp::create(builder, builder.getUnknownLoc(), "haz").getResult()); + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] + // CHECK-MESSAGES: :[[@LINE+2]]:5: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder] + builder.create<OperandOp>(builder.getUnknownLoc(), + builder.create<NamedOp>(builder.getUnknownLoc(), "haz").getResult()); } diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp index 4c847b5..0cb58c2 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp @@ -73,3 +73,18 @@ void ignoreNonConstRefOps() { int* p2 {nullptr}; int*& r2 = (int*&)p2; } + +void pointer_to_pointer_param(int**); +void pass_address_to_pointer_to_pointer() { + int i = 0; + int* ip = &i; + // CHECK-NOT: warning + pointer_to_pointer_param(&ip); +} + +void void_pointer_to_pointer_param(void**); +void pass_address_to_void_pointer_to_pointer() { + void* ptr = nullptr; + // CHECK-NOT: warning + void_pointer_to_pointer_param(&ptr); +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp index c23c355..dff73ae 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp @@ -1,7 +1,8 @@ // RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \ // RUN: -config="{CheckOptions: {\ // RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; ::my::other::Mutex', \ -// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 'safe::awaitable; ::transformable::awaitable' \ +// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 'safe::awaitable; ::transformable::awaitable', \ +// RUN: misc-coroutine-hostile-raii.AllowedCallees: 'safe::AwaitFunc; ::safe::Obj::AwaitMethod; retExemptedAwaitable' \ // RUN: }}" namespace std { @@ -145,18 +146,27 @@ namespace safe { void await_suspend(std::coroutine_handle<>) noexcept {} void await_resume() noexcept {} }; + std::suspend_always AwaitFunc(); + struct Obj { + std::suspend_always AwaitMethod(); + }; } // namespace safe ReturnObject RAIISafeSuspendTest() { absl::Mutex a; co_await safe::awaitable{}; using other = safe::awaitable; co_await other{}; + co_await safe::AwaitFunc(); + co_await safe::Obj().AwaitMethod(); } // ================================================================================ // Safe transformable awaitable // ================================================================================ -struct transformable { struct awaitable{}; }; +struct transformable { + struct awaitable{}; + struct unsafe_awaitable{}; +}; using alias_transformable_awaitable = transformable::awaitable; struct UseTransformAwaitable { struct promise_type { @@ -165,13 +175,18 @@ struct UseTransformAwaitable { std::suspend_always final_suspend() noexcept { return {}; } void unhandled_exception() {} std::suspend_always await_transform(transformable::awaitable) { return {}; } + std::suspend_always await_transform(transformable::unsafe_awaitable) { + return {}; + } }; }; auto retAwaitable() { return transformable::awaitable{}; } +auto retExemptedAwaitable() { return transformable::unsafe_awaitable{}; } UseTransformAwaitable RAIISafeSuspendTest2() { absl::Mutex a; co_await retAwaitable(); + co_await retExemptedAwaitable(); co_await transformable::awaitable{}; co_await alias_transformable_awaitable{}; } diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/limited-randomness.c b/clang-tools-extra/test/clang-tidy/checkers/misc/predictable-rand.c index 32e4a07..d823309 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/limited-randomness.c +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/predictable-rand.c @@ -1,11 +1,11 @@ -// RUN: %check_clang_tidy %s cert-msc30-c %t +// RUN: %check_clang_tidy %s misc-predictable-rand %t extern int rand(void); int nonrand(void); int cTest(void) { int i = rand(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness [cert-msc30-c] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness [misc-predictable-rand] int k = nonrand(); diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert/limited-randomness.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/predictable-rand.cpp index 845b735..8f00186 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert/limited-randomness.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/predictable-rand.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s cert-msc50-cpp %t +// RUN: %check_clang_tidy %s misc-predictable-rand %t int rand(); int rand(int); @@ -13,16 +13,16 @@ namespace nonstd { void testFunction1() { int i = std::rand(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [cert-msc50-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [misc-predictable-rand] int j = ::rand(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [cert-msc50-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [misc-predictable-rand] int k = rand(i); int l = nonstd::rand(); int m = rand(); - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [cert-msc50-cpp] + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [misc-predictable-rand] } diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-style-cast.c b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-style-cast.c new file mode 100644 index 0000000..7dfdc7b --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-style-cast.c @@ -0,0 +1,24 @@ +// RUN: %check_clang_tidy %s modernize-avoid-c-style-cast %t -- -- -x c +// The testing script always adds .cpp extension to the input file name, so we +// need to run clang-tidy directly in order to verify handling of .c files: +// RUN: clang-tidy --checks=-*,modernize-avoid-c-style-cast %s -- -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:' +// RUN: cp %s %t.main_file.cpp +// RUN: clang-tidy --checks=-*,modernize-avoid-c-style-cast -header-filter='.*' %t.main_file.cpp -- -I%S -DTEST_INCLUDE -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:' + +#ifdef TEST_INCLUDE + +#undef TEST_INCLUDE +#include "avoid-c-style-cast.c" + +#else + +void f(const char *cpc) { + const char *cpc2 = (const char*)cpc; + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [modernize-avoid-c-style-cast] + // CHECK-FIXES: const char *cpc2 = cpc; + char *pc = (char*)cpc; + typedef const char *Typedef1; + (Typedef1)cpc; +} + +#endif diff --git a/clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-style-cast.cpp index 7ccdf70..52b4d47 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-style-cast.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy -std=c++11-or-later %s google-readability-casting %t -- -- -fexceptions +// RUN: %check_clang_tidy -std=c++11-or-later %s modernize-avoid-c-style-cast %t -- -- -fexceptions bool g() { return false; } @@ -8,14 +8,14 @@ struct Y : public X {}; void f(int a, double b, const char *cpc, const void *cpv, X *pX) { const char *cpc2 = (const char*)cpc; - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [modernize-avoid-c-style-cast] // CHECK-FIXES: const char *cpc2 = cpc; typedef const char *Typedef1; typedef const char *Typedef2; Typedef1 t1; (Typedef2)t1; - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: C-style casts are discouraged; use static_cast (if needed, the cast may be redundant) [google-readability-casting] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: C-style casts are discouraged; use static_cast (if needed, the cast may be redundant) [modernize-avoid-c-style-cast] // CHECK-FIXES: static_cast<Typedef2>(t1); (const char*)t1; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed @@ -28,7 +28,7 @@ void f(int a, double b, const char *cpc, const void *cpv, X *pX) { // CHECK-FIXES: t1; char *pc = (char*)cpc; - // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use const_cast [google-readability-casting] + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use const_cast [modernize-avoid-c-style-cast] // CHECK-FIXES: char *pc = const_cast<char*>(cpc); typedef char Char; Char *pChar = (Char*)pc; @@ -102,9 +102,15 @@ void f(int a, double b, const char *cpc, const void *cpv, X *pX) { // CHECK-FIXES: b1 = static_cast<int>(b); Y *pB = (Y*)pX; - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast {{.*}} + // CHECK-FIXES: Y *pB = static_cast<Y*>(pX); Y &rB = (Y&)*pX; - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast {{.*}} + // CHECK-FIXES: Y &rB = static_cast<Y&>(*pX); + + void *vp = (void *) pX; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}}; use reinterpret_cast + // CHECK-FIXES: void *vp = reinterpret_cast<void *>(pX); const char *pc3 = (const char*)cpv; // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}; use static_cast [ diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp index ec37f07..63972cc 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp @@ -54,6 +54,12 @@ void printf_deceptive_newline() { // CHECK-FIXES: std::println("Hello"); } +void printf_utf8_text() { + printf("你好世界\n"); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'printf' [modernize-use-std-print] + // CHECK-FIXES: std::println("你好世界"); +} + void printf_crlf_newline() { printf("Hello\r\n"); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::print' instead of 'printf' [modernize-use-std-print] @@ -303,6 +309,12 @@ void fprintf_simple() { // CHECK-FIXES: std::print(stderr, "Hello"); } +void fprintf_utf8_text() { + fprintf(stderr, "你好世界\n"); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::println' instead of 'fprintf' [modernize-use-std-print] + // CHECK-FIXES: std::println(stderr, "你好世界"); +} + void std_printf_simple() { std::printf("std::Hello"); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use 'std::print' instead of 'printf' [modernize-use-std-print] diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/pack_begin.h b/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/pack_begin.h new file mode 100644 index 0000000..fc9369c --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/pack_begin.h @@ -0,0 +1 @@ +// Intentionally unguarded begin-pack header used in tests diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/pack_end.h b/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/pack_end.h new file mode 100644 index 0000000..78fd0a9 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/pack_end.h @@ -0,0 +1 @@ +// Intentionally unguarded end-pack header used in tests diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp index a8e0eb6..2ed1e93 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp @@ -35,6 +35,12 @@ template <typename T> struct enable_if<true, T> { typedef T type; }; + +template <typename T> +struct unique_ptr { + T &operator*() const; + T *operator->() const; +}; } template <typename T> @@ -144,3 +150,20 @@ int *r() { // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer] // CHECK-FIXES: return holder.v.data(); } + +void s(std::unique_ptr<std::vector<unsigned char>> p) { + f(&(*p)[0]); + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer] + // CHECK-FIXES: f((*p).data()); +} + +void t(std::unique_ptr<container_without_data<unsigned char>> p) { + // p has no "data" member function, so no warning + f(&(*p)[0]); +} + +template <typename T> +void u(std::unique_ptr<T> p) { + // we don't know if 'T' will always have "data" member function, so no warning + f(&(*p)[0]); +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/duplicate-include-ignored-files.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/duplicate-include-ignored-files.cpp new file mode 100644 index 0000000..cdc2f44 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/duplicate-include-ignored-files.cpp @@ -0,0 +1,24 @@ +// RUN: %check_clang_tidy %s readability-duplicate-include %t -- \ +// RUN: -config="{CheckOptions: {readability-duplicate-include.IgnoredFilesList: 'pack_.*\\.h'}}" \ +// RUN: -header-filter='' -- -I %S/Inputs/duplicate-include + +int g; +#include "duplicate-include.h" +int h; +#include "duplicate-include.h" +int i; +// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: duplicate include [readability-duplicate-include] +// CHECK-FIXES: int g; +// CHECK-FIXES-NEXT: #include "duplicate-include.h" +// CHECK-FIXES-NEXT: int h; +// CHECK-FIXES-NEXT: int i; + +#include "pack_begin.h" +struct A { int x; }; +#include "pack_end.h" + +#include "pack_begin.h" +struct B { int x; }; +#include "pack_end.h" + +// No warning here. diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-declaration-parameter-name.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-declaration-parameter-name.cpp index 9822432..119a3c85 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-declaration-parameter-name.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/inconsistent-declaration-parameter-name.cpp @@ -191,3 +191,26 @@ struct S { void S::f(int y) { } + +////////////////////////////////////////////////////// + +template<typename... Args> +void variadicFunctionNoWarning(Args... args); + +template<> +void variadicFunctionNoWarning(int a) {} + +template<> +void variadicFunctionNoWarning(int a, int b) {} + +template<typename... Args> +void variadicFunction2WithWarning(int fixed, Args... args); + +template<> +void variadicFunction2WithWarning(int fixed, int a) {} + +template<> +// CHECK-MESSAGES: :[[@LINE+3]]:6: warning: function template specialization 'variadicFunction2WithWarning<float>' has a primary template +// CHECK-MESSAGES: :[[@LINE-7]]:6: note: the primary template declaration seen here +// CHECK-MESSAGES: :[[@LINE+1]]:6: note: differing parameters are named here: ('wrong'), in primary template declaration: ('fixed') +void variadicFunction2WithWarning(int wrong, float a) {} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp index fa91995..3e723b8 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp @@ -235,3 +235,13 @@ void testRedundantDependentNTTPCasting() { // CHECK-MESSAGES: :[[@LINE-4]]:25: note: source type originates from referencing this non-type template parameter // CHECK-FIXES: T a = V; } + +namespace gh170476 { +int f(void); +int g1() { + int (*fp)() = (int(*)(void))&f; + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant explicit casting to the same type 'int (*)()' as the sub-expression, remove this casting [readability-redundant-casting] + // CHECK-FIXES: int (*fp)() = (&f); + return fp(); +} +} // namespace gh170476 diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-control-flow.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-control-flow.cpp index 7764490..94e4fc6 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-control-flow.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-control-flow.cpp @@ -7,16 +7,16 @@ void f() { return; } // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement at the end of a function with a void return type [readability-redundant-control-flow] -// CHECK-FIXES: void f() { -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: void f() { +// CHECK-FIXES-NEXT: } void g() { f(); return; } // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement -// CHECK-FIXES: f(); -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: f(); +// CHECK-FIXES-NEXT: } void g(int i) { if (i < 0) { @@ -40,8 +40,8 @@ void k() { } } // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement at the end of loop statement -// CHECK-FIXES: for (int i = 0; i < 10; ++i) { -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: for (int i = 0; i < 10; ++i) { +// CHECK-FIXES-NEXT: } void k2() { int v[10] = { 0 }; @@ -50,8 +50,8 @@ void k2() { } } // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement -// CHECK-FIXES: for (auto i : v) { -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: for (auto i : v) { +// CHECK-FIXES-NEXT: } void m() { int i = 0; @@ -61,8 +61,8 @@ void m() { } while (i < 10); } // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement -// CHECK-FIXES: {{^ do {$}} -// CHECK-FIXES-NEXT: ++i; +// CHECK-FIXES: do { +// CHECK-FIXES-NEXT: ++i; // CHECK-FIXES-NEXT: } while (i < 10); void p() { @@ -73,9 +73,9 @@ void p() { } } // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement -// CHECK-FIXES: while (i < 10) { -// CHECK-FIXES-NEXT: ++i; -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: while (i < 10) { +// CHECK-FIXES-NEXT: ++i; +// CHECK-FIXES-NEXT: } void im_not_dead(int i) { if (i > 0) { @@ -176,10 +176,10 @@ void template_return(T check) { return; } // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement -// CHECK-FIXES: if (check < T(0)) { -// CHECK-FIXES-NEXT: {{^ return;$}} -// CHECK-FIXES-NEXT: {{^ *}$}} -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: if (check < T(0)) { +// CHECK-FIXES-NEXT: return; +// CHECK-FIXES-NEXT: } +// CHECK-FIXES-NEXT: } template <> void template_return(int check) { @@ -189,10 +189,10 @@ void template_return(int check) { return; } // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement -// CHECK-FIXES: if (check < 0) { -// CHECK-FIXES-NEXT: {{^ return;$}} -// CHECK-FIXES-NEXT: {{^ *}$}} -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: if (check < 0) { +// CHECK-FIXES-NEXT: return; +// CHECK-FIXES-NEXT: } +// CHECK-FIXES-NEXT: } template <typename T> void template_loop(T end) { @@ -201,8 +201,8 @@ void template_loop(T end) { } } // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement -// CHECK-FIXES: for (T i = 0; i < end; ++i) { -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: for (T i = 0; i < end; ++i) { +// CHECK-FIXES-NEXT: } template <> void template_loop(int end) { @@ -211,8 +211,8 @@ void template_loop(int end) { } } // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement -// CHECK-FIXES: for (int i = 0; i < end; ++i) { -// CHECK-FIXES-NEXT: {{^ *}$}} +// CHECK-FIXES: for (int i = 0; i < end; ++i) { +// CHECK-FIXES-NEXT: } void call_templates() { template_return(10); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp index 2efafd1..e8fcd9b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp @@ -267,3 +267,27 @@ WHOLE_TYPE_IN_MACRO Macro2; #define WHOLE_DECLARATION_IN_MACRO typename NotDependent::R Macro3 WHOLE_DECLARATION_IN_MACRO; + +template <typename T> struct Wrapper {}; +template <typename T> +struct ClassWrapper { + using R = T; + Wrapper<R> f(); +}; + +template <typename T> +Wrapper<typename ClassWrapper<T>::R> ClassWrapper<T>::f() { + return {}; +} + +template <typename T> struct StructWrapper {}; +template <typename T> +class ClassWithNestedStruct { + struct Nested {}; + StructWrapper<Nested> f(); +}; + +template <typename T> +StructWrapper<typename ClassWithNestedStruct<T>::Nested> ClassWithNestedStruct<T>::f() { + return {}; +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/use-concise-preprocessor-directives.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/use-concise-preprocessor-directives.cpp index 53e079b..b8a4953 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/use-concise-preprocessor-directives.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/use-concise-preprocessor-directives.cpp @@ -30,6 +30,14 @@ // CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives] // CHECK-FIXES: #ifdef FOO +#if(defined(FOO)) +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] +// CHECK-FIXES-23: #elifdef BAR +#elif(defined(BAR)) +#endif + +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives] +// CHECK-FIXES: #ifdef FOO #if (defined FOO) // CHECK-MESSAGES-23: :[[@LINE+2]]:4: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] // CHECK-FIXES-23: # elifdef BAR diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp index 35ade8a..3557018 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/use-std-min-max.cpp @@ -273,3 +273,99 @@ void useRight() { } } // namespace gh121676 + +void testComments() { + int box_depth = 10; + int max_depth = 5; + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // here + if (box_depth > max_depth) // here + { + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); /* here */ + if (box_depth > max_depth) /* here */ + { + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // here + if (box_depth > max_depth) + // here + { + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); /* here */ + if (box_depth > max_depth) + /* here */ + { + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+4]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); /* here + // CHECK-FIXES-NEXT: and here + // CHECK-FIXES-NEXT: */ + if (box_depth > max_depth) /* here + and here + */ + { + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); /* here */ + if (box_depth > max_depth) { /* here */ + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // here + if (box_depth > max_depth) { // here + box_depth = max_depth; + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); /* here */ + if (box_depth > max_depth) { + box_depth = max_depth; /* here */ + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // here + if (box_depth > max_depth) { + box_depth = max_depth; // here + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); /* here */ + if (box_depth > max_depth) { + box_depth = max_depth; + /* here */ + } + + // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // here + if (box_depth > max_depth) { + box_depth = max_depth; + // here + } + + // CHECK-MESSAGES: :[[@LINE+5]]:3: warning: use `std::min` instead of `>` [readability-use-std-min-max] + // CHECK-FIXES: box_depth = std::min(box_depth, max_depth); // here + // CHECK-FIXES-NEXT: // and + // CHECK-FIXES-NEXT: /* there + // CHECK-FIXES-NEXT: again*/ + if (box_depth > max_depth) { + // here + box_depth = max_depth; // and + /* there + again*/ + } +} diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/param/parameters.txt b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/param/parameters.txt index a6d8fa7e..5cf5693 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/param/parameters.txt +++ b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/param/parameters.txt @@ -1,2 +1,2 @@ --checks='-*,llvm-namespace-comment' +-checks=-*,llvm-namespace-comment --warnings-as-errors=llvm-namespace-comment diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/alphabetical-order.test b/clang-tools-extra/test/clang-tidy/infrastructure/alphabetical-order.test new file mode 100644 index 0000000..6cb0da7 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/alphabetical-order.test @@ -0,0 +1,5 @@ +// RUN: %python %S/../../../clang-tidy/tool/check_alphabetical_order.py -o %t.clang-tidy-checks-list.rst +// RUN: diff --strip-trailing-cr %S/../../../docs/clang-tidy/checks/list.rst %t.clang-tidy-checks-list.rst + +// RUN: %python %S/../../../clang-tidy/tool/check_alphabetical_order.py -o %t.ReleaseNotes.rst +// RUN: diff --strip-trailing-cr %S/../../../docs/ReleaseNotes.rst %t.ReleaseNotes.rst diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/empty-database.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/empty-database.cpp index c4c504c..0331dcc 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/empty-database.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/empty-database.cpp @@ -1,5 +1,5 @@ // UNSUPPORTED: system-windows -// RUN: clang-tidy -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s +// RUN: clang-tidy -checks='-*,clang-analyzer-*' -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s // CHECK: 'directory' field of compilation database is empty; using the current working directory instead. diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/invalid-database.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/invalid-database.cpp index 7935385..ea9e102 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/invalid-database.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/invalid-database.cpp @@ -1,5 +1,5 @@ // UNSUPPORTED: system-windows -// RUN: not --crash clang-tidy -p %S/Inputs/invalid-database %s 2>&1 | FileCheck %s +// RUN: not --crash clang-tidy -checks='-*,clang-analyzer-*' -p %S/Inputs/invalid-database %s 2>&1 | FileCheck %s // CHECK: LLVM ERROR: Cannot chdir into "/invalid/"! diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-LIFO.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-LIFO.cpp index ee5b1cc..e86b3df 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-LIFO.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-LIFO.cpp @@ -1,11 +1,11 @@ -// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,google-readability-casting' 2>&1 | FileCheck %s +// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,modernize-avoid-c-style-cast' 2>&1 | FileCheck %s // NOLINTBEGIN(google-explicit-constructor) -// NOLINTBEGIN(google-readability-casting) +// NOLINTBEGIN(modernize-avoid-c-style-cast) class A { A(int i); }; auto Num = (unsigned int)(-1); // NOLINTEND(google-explicit-constructor) -// NOLINTEND(google-readability-casting) +// NOLINTEND(modernize-avoid-c-style-cast) // Note: the expected output has been split over several lines so that clang-tidy // does not see the "no lint" suppression comment and mistakenly assume it diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-multiple-end-single.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-multiple-end-single.cpp index 150913c..156a5cb 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-multiple-end-single.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-multiple-end-single.cpp @@ -1,10 +1,10 @@ -// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,google-readability-casting' 2>&1 | FileCheck %s +// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,modernize-avoid-c-style-cast' 2>&1 | FileCheck %s -// NOLINTBEGIN(google-explicit-constructor,google-readability-casting) +// NOLINTBEGIN(google-explicit-constructor,modernize-avoid-c-style-cast) class B { B(int i); }; // NOLINTEND(google-explicit-constructor) auto Num2 = (unsigned int)(-1); -// NOLINTEND(google-readability-casting) +// NOLINTEND(modernize-avoid-c-style-cast) // Note: the expected output has been split over several lines so that clang-tidy // does not see the "no lint" suppression comment and mistakenly assume it diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-single-end-multiple.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-single-end-multiple.cpp index f9a915c..8372132 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-single-end-multiple.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-single-end-multiple.cpp @@ -1,10 +1,10 @@ -// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,google-readability-casting' 2>&1 | FileCheck %s +// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,modernize-avoid-c-style-cast' 2>&1 | FileCheck %s // NOLINTBEGIN(google-explicit-constructor) -// NOLINTBEGIN(google-readability-casting) +// NOLINTBEGIN(modernize-avoid-c-style-cast) class B { B(int i); }; auto Num2 = (unsigned int)(-1); -// NOLINTEND(google-explicit-constructor,google-readability-casting) +// NOLINTEND(google-explicit-constructor,modernize-avoid-c-style-cast) // Note: the expected output has been split over several lines so that clang-tidy // does not see the "no lint" suppression comment and mistakenly assume it diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp index 8d7786f..ddd399d 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp @@ -1,9 +1,9 @@ -// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,google-readability-casting' 2>&1 | FileCheck %s +// RUN: not clang-tidy %s --checks='-*,google-explicit-constructor,modernize-avoid-c-style-cast' 2>&1 | FileCheck %s // NOLINTBEGIN(google-explicit-constructor) class A { A(int i); }; auto Num = (unsigned int)(-1); -// NOLINTEND(google-readability-casting) +// NOLINTEND(modernize-avoid-c-style-cast) // Note: the expected output has been split over several lines so that clang-tidy // does not see the "no lint" suppression comment and mistakenly assume it diff --git a/clang-tools-extra/test/lit.cfg.py b/clang-tools-extra/test/lit.cfg.py index c1da37d..c39ea29 100644 --- a/clang-tools-extra/test/lit.cfg.py +++ b/clang-tools-extra/test/lit.cfg.py @@ -57,6 +57,7 @@ if config.clang_tidy_staticanalyzer: if config.clang_tidy_custom_check: config.available_features.add("custom-check") python_exec = shlex.quote(config.python_executable) +config.substitutions.append(("%python", python_exec)) check_clang_tidy = os.path.join( config.test_source_root, "clang-tidy", "check_clang_tidy.py" ) diff --git a/clang-tools-extra/test/pp-trace/pp-trace-include.cpp b/clang-tools-extra/test/pp-trace/pp-trace-include.cpp index ea9896e..fccbd9b 100644 --- a/clang-tools-extra/test/pp-trace/pp-trace-include.cpp +++ b/clang-tools-extra/test/pp-trace/pp-trace-include.cpp @@ -39,7 +39,6 @@ // CHECK-NEXT: Reason: EnterFile // CHECK-NEXT: FileType: C_User // CHECK-NEXT: PrevFID: (invalid) -// CHECK: - Callback: MacroDefined // CHECK: - Callback: FileChanged // CHECK-NEXT: Loc: "<built-in>:1:1" // CHECK-NEXT: Reason: ExitFile diff --git a/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp b/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp index 7c2a231..5bd38e0 100644 --- a/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp +++ b/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp @@ -40,7 +40,6 @@ X // CHECK-NEXT: MacroNameTok: __STDC_EMBED_EMPTY__ // CHECK-NEXT: MacroDirective: MD_Define // CHECK: - Callback: MacroDefined -// CHECK: - Callback: MacroDefined // CHECK-NEXT: MacroNameTok: MACRO // CHECK-NEXT: MacroDirective: MD_Define // CHECK-NEXT: - Callback: MacroExpands |
