Remove trailing whitespace in docs and clang-tidy sources.
llvm-svn: 289547
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/TokenKinds.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "llvm/ADT/APSInt.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
@@ -59,7 +59,7 @@ Modularize Command Line Options
|
||||
|
||||
Generate a module map and output it to the given file. See the description
|
||||
in :ref:`module-map-generation`.
|
||||
|
||||
|
||||
.. option:: -problem-files-list=<problem-files-list-file-name>
|
||||
|
||||
For use only with module map assistant. Input list of files that
|
||||
|
||||
@@ -81,7 +81,7 @@ Improvements to clang-tidy
|
||||
Warns if an object is used after it has been moved, without an intervening
|
||||
reinitialization.
|
||||
|
||||
- New `cppcoreguidelines-no-malloc
|
||||
- New `cppcoreguidelines-no-malloc
|
||||
<http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-no-malloc.html>`_ check
|
||||
warns if C-style memory management is used and suggests the use of RAII.
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ do perform better error checking.
|
||||
.. code-block:: c
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
void func(const char *buff) {
|
||||
int si;
|
||||
|
||||
|
||||
if (buff) {
|
||||
si = atoi(buff); /* 'atoi' used to convert a string to an integer, but function will
|
||||
not report conversion errors; consider using 'strtol' instead. */
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
cppcoreguidelines-no-malloc
|
||||
===========================
|
||||
|
||||
This check handles C-Style memory management using ``malloc()``, ``realloc()``,
|
||||
``calloc()`` and ``free()``. It warns about its use and tries to suggest the use
|
||||
This check handles C-Style memory management using ``malloc()``, ``realloc()``,
|
||||
``calloc()`` and ``free()``. It warns about its use and tries to suggest the use
|
||||
of an appropriate RAII object.
|
||||
See `C++ Core Guidelines
|
||||
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rr-mallocfree>
|
||||
@@ -16,11 +16,11 @@ easily transformed automatically into RAII.
|
||||
|
||||
// Warns each of the following lines.
|
||||
// Containers like std::vector or std::string should be used.
|
||||
char* some_string = (char*) malloc(sizeof(char) * 20);
|
||||
char* some_string = (char*) malloc(sizeof(char) * 20);
|
||||
char* some_string = (char*) realloc(sizeof(char) * 30);
|
||||
free(some_string);
|
||||
|
||||
int* int_array = (int*) calloc(30, sizeof(int));
|
||||
int* int_array = (int*) calloc(30, sizeof(int));
|
||||
|
||||
// Rather use a smartpointer or stack variable.
|
||||
struct some_struct* s = (struct some_struct*) malloc(sizeof(struct some_struct));
|
||||
|
||||
@@ -35,7 +35,7 @@ pointer.
|
||||
class Point {
|
||||
[...]
|
||||
size_t size() { return sizeof(this); } // should probably be sizeof(*this)
|
||||
[...]
|
||||
[...]
|
||||
};
|
||||
|
||||
Suspicious usage of 'sizeof(char*)'
|
||||
|
||||
@@ -139,7 +139,7 @@ Example:
|
||||
public:
|
||||
= // using -fdelayed-template-parsing (default on Windows)
|
||||
= C(const std::string &S) : S(S) {}
|
||||
|
||||
|
||||
+ // using -fno-delayed-template-parsing (default on non-Windows systems)
|
||||
+ C(std::string S) : S(std::move(S)) {}
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ conversions.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
// Non-transparent functor
|
||||
// Non-transparent functor
|
||||
std::map<int, std::string, std::greater<int>> s;
|
||||
|
||||
// Transparent functor.
|
||||
@@ -19,12 +19,12 @@ conversions.
|
||||
// Non-transparent functor
|
||||
using MyFunctor = std::less<MyType>;
|
||||
|
||||
It is not always a safe transformation though. The following case will be
|
||||
It is not always a safe transformation though. The following case will be
|
||||
untouched to preserve the semantics.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
// Non-transparent functor
|
||||
// Non-transparent functor
|
||||
std::map<const char *, std::string, std::greater<std::string>> s;
|
||||
|
||||
Options
|
||||
|
||||
@@ -104,12 +104,12 @@ An overview of all the command-line options:
|
||||
|
||||
clang-tidy options:
|
||||
|
||||
-analyze-temporary-dtors -
|
||||
-analyze-temporary-dtors -
|
||||
Enable temporary destructor-aware analysis in
|
||||
clang-analyzer- checks.
|
||||
This option overrides the value read from a
|
||||
.clang-tidy file.
|
||||
-checks=<string> -
|
||||
-checks=<string> -
|
||||
Comma-separated list of globs with optional '-'
|
||||
prefix. Globs are processed in order of
|
||||
appearance in the list. Globs without '-'
|
||||
@@ -119,7 +119,7 @@ An overview of all the command-line options:
|
||||
checks. This option's value is appended to the
|
||||
value of the 'Checks' option in .clang-tidy
|
||||
file, if any.
|
||||
-config=<string> -
|
||||
-config=<string> -
|
||||
Specifies a configuration in YAML/JSON format:
|
||||
-config="{Checks: '*',
|
||||
CheckOptions: [{key: x,
|
||||
@@ -127,7 +127,7 @@ An overview of all the command-line options:
|
||||
When the value is empty, clang-tidy will
|
||||
attempt to find a file named .clang-tidy for
|
||||
each source file in its parent directories.
|
||||
-dump-config -
|
||||
-dump-config -
|
||||
Dumps configuration in the YAML format to
|
||||
stdout. This option can be used along with a
|
||||
file name (and '--' if the file is outside of a
|
||||
@@ -136,29 +136,29 @@ An overview of all the command-line options:
|
||||
printed.
|
||||
Use along with -checks=* to include
|
||||
configuration of all checks.
|
||||
-enable-check-profile -
|
||||
-enable-check-profile -
|
||||
Enable per-check timing profiles, and print a
|
||||
report to stderr.
|
||||
-explain-config -
|
||||
-explain-config -
|
||||
For each enabled check explains, where it is
|
||||
enabled, i.e. in clang-tidy binary, command
|
||||
line or a specific configuration file.
|
||||
-export-fixes=<filename> -
|
||||
-export-fixes=<filename> -
|
||||
YAML file to store suggested fixes in. The
|
||||
stored fixes can be applied to the input source
|
||||
code with clang-apply-replacements.
|
||||
-extra-arg=<string> - Additional argument to append to the compiler command line
|
||||
-extra-arg-before=<string> - Additional argument to prepend to the compiler command line
|
||||
-fix -
|
||||
-fix -
|
||||
Apply suggested fixes. Without -fix-errors
|
||||
clang-tidy will bail out if any compilation
|
||||
errors were found.
|
||||
-fix-errors -
|
||||
-fix-errors -
|
||||
Apply suggested fixes even if compilation
|
||||
errors were found. If compiler errors have
|
||||
attached fix-its, clang-tidy will apply them as
|
||||
well.
|
||||
-header-filter=<string> -
|
||||
-header-filter=<string> -
|
||||
Regular expression matching the names of the
|
||||
headers to output diagnostics from. Diagnostics
|
||||
from the main file of each translation unit are
|
||||
@@ -166,7 +166,7 @@ An overview of all the command-line options:
|
||||
Can be used together with -line-filter.
|
||||
This option overrides the 'HeaderFilter' option
|
||||
in .clang-tidy file, if any.
|
||||
-line-filter=<string> -
|
||||
-line-filter=<string> -
|
||||
List of files with line ranges to filter the
|
||||
warnings. Can be used together with
|
||||
-header-filter. The format of the list is a
|
||||
@@ -175,7 +175,7 @@ An overview of all the command-line options:
|
||||
{"name":"file1.cpp","lines":[[1,3],[5,7]]},
|
||||
{"name":"file2.h"}
|
||||
]
|
||||
-list-checks -
|
||||
-list-checks -
|
||||
List all enabled checks and exit. Use with
|
||||
-checks=* to list all available checks.
|
||||
-p=<string> - Build path
|
||||
@@ -183,7 +183,7 @@ An overview of all the command-line options:
|
||||
Fallback style for reformatting after inserting fixes
|
||||
if there is no clang-format config file found.
|
||||
-system-headers - Display the errors from system headers.
|
||||
-warnings-as-errors=<string> -
|
||||
-warnings-as-errors=<string> -
|
||||
Upgrades warnings to errors. Same format as
|
||||
'-checks'.
|
||||
This option's value is appended to the value of
|
||||
@@ -502,7 +502,7 @@ the check implements and what the current values are (e.g. for the
|
||||
class MyCheck : public ClangTidyCheck {
|
||||
const unsigned SomeOption1;
|
||||
const std::string SomeOption2;
|
||||
|
||||
|
||||
public:
|
||||
MyCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
|
||||
@@ -27,7 +27,7 @@ void test_to_string1() {
|
||||
// CHECK-FIXES: auto xa = std::to_string(5);
|
||||
|
||||
auto z = boost::lexical_cast<std::string>(42LL);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::to_string
|
||||
// CHECK-FIXES: auto z = std::to_string(42LL);
|
||||
|
||||
// this should not trigger
|
||||
@@ -49,22 +49,22 @@ void test_to_string2() {
|
||||
bool j;
|
||||
|
||||
fun(boost::lexical_cast<std::string>(a));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-FIXES: fun(std::to_string(a));
|
||||
fun(boost::lexical_cast<std::string>(b));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-FIXES: fun(std::to_string(b));
|
||||
fun(boost::lexical_cast<std::string>(c));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-FIXES: fun(std::to_string(c));
|
||||
fun(boost::lexical_cast<std::string>(d));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-FIXES: fun(std::to_string(d));
|
||||
fun(boost::lexical_cast<std::string>(e));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-FIXES: fun(std::to_string(e));
|
||||
fun(boost::lexical_cast<std::string>(f));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
|
||||
// CHECK-FIXES: fun(std::to_string(f));
|
||||
|
||||
// No change for floating numbers.
|
||||
@@ -93,19 +93,19 @@ void test_to_wstring() {
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring instead of boost::lexical_cast<std::wstring> [boost-use-to-string]
|
||||
// CHECK-FIXES: fun(std::to_wstring(a));
|
||||
fun(boost::lexical_cast<std::wstring>(b));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-FIXES: fun(std::to_wstring(b));
|
||||
fun(boost::lexical_cast<std::wstring>(c));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-FIXES: fun(std::to_wstring(c));
|
||||
fun(boost::lexical_cast<std::wstring>(d));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-FIXES: fun(std::to_wstring(d));
|
||||
fun(boost::lexical_cast<std::wstring>(e));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-FIXES: fun(std::to_wstring(e));
|
||||
fun(boost::lexical_cast<std::wstring>(f));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
|
||||
// CHECK-FIXES: fun(std::to_wstring(f));
|
||||
|
||||
// No change for floating numbers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %check_clang_tidy %s misc-forward-declaration-namespace %t
|
||||
// RUN: %check_clang_tidy %s misc-forward-declaration-namespace %t
|
||||
|
||||
namespace {
|
||||
// This is a declaration in a wrong namespace.
|
||||
|
||||
@@ -330,7 +330,7 @@ int TestRelational(int X, int Y) {
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
|
||||
|
||||
if (X < 7 && X <= 5) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
if (X < 7 && X <= 6) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: equivalent expression on both side of logical operator
|
||||
if (X < 7 && X <= 7) return 1;
|
||||
@@ -352,27 +352,27 @@ int TestRelational(int X, int Y) {
|
||||
if (X <= 7 && X <= 7) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
|
||||
if (X <= 7 && X <= 8) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: expression is redundant
|
||||
|
||||
if (X == 11 && X > 10) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: expression is redundant
|
||||
if (X == 11 && X < 12) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: expression is redundant
|
||||
if (X > 10 && X == 11) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
if (X < 12 && X == 11) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
|
||||
if (X != 11 && X == 42) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
if (X != 11 && X > 11) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
if (X != 11 && X < 11) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
if (X != 11 && X < 8) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
if (X != 11 && X > 14) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
|
||||
|
||||
if (X < 7 || X < 6) return 1;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
|
||||
@@ -480,6 +480,6 @@ int TestWithMinMaxInt(int X) {
|
||||
|
||||
if (X > 0x7FFFFFFF || X < ((-0x7FFFFFFF)-1)) return 1;
|
||||
if (X <= 0x7FFFFFFF && X >= ((-0x7FFFFFFF)-1)) return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ int Test1(const char* ptr) {
|
||||
sum += (2 * sizeof(char)) * sizeof(int);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
|
||||
if (sizeof(A) < 0x100000) sum += 42;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: suspicious comparison of 'sizeof(expr)' to a constant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: suspicious comparison of 'sizeof(expr)' to a constant
|
||||
if (sizeof(A) <= 0xFFFFFFFEU) sum += 42;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: suspicious comparison of 'sizeof(expr)' to a constant
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: suspicious comparison of 'sizeof(expr)' to a constant
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -134,31 +134,31 @@ int Test5() {
|
||||
|
||||
int sum = 0;
|
||||
sum += sizeof(&S.arr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(&kGlocalMyStruct.arr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(&kGlocalMyStructPtr->arr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(S.arr + 0);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(+ S.arr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof((int*)S.arr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
|
||||
sum += sizeof(S.ptr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(kGlocalMyStruct.ptr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(kGlocalMyStructPtr->ptr);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
|
||||
sum += sizeof(&kGlocalMyStruct);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(&S);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
sum += sizeof(&A10);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ extern const char kText3[];
|
||||
void Test() {
|
||||
std::string str('x', 4);
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [misc-string-constructor]
|
||||
// CHECK-FIXES: std::string str(4, 'x');
|
||||
// CHECK-FIXES: std::string str(4, 'x');
|
||||
std::wstring wstr(L'x', 4);
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor parameters are probably swapped
|
||||
// CHECK-FIXES: std::wstring wstr(4, L'x');
|
||||
// CHECK-FIXES: std::wstring wstr(4, L'x');
|
||||
std::string s0(0, 'x');
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
|
||||
std::string s1(-4, 'x');
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
|
||||
std::string s2(0x1000000, 'x');
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
|
||||
|
||||
|
||||
std::string q0("test", 0);
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
|
||||
std::string q1(kText, -4);
|
||||
|
||||
@@ -48,6 +48,6 @@ void foo() {
|
||||
#define PARAMS 1.0, 3
|
||||
#define CALL(P) F(P)
|
||||
CALL(PARAMS);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
|
||||
// In macro, don't emit fixits.
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
|
||||
// In macro, don't emit fixits.
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ void f() {
|
||||
std::vector<int> v;
|
||||
|
||||
std::vector<int>(v).swap(v);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should be used to reduce the capacity of a shrinkable container [modernize-shrink-to-fit]
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should be used to reduce the capacity of a shrinkable container [modernize-shrink-to-fit]
|
||||
// CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
|
||||
|
||||
std::vector<int> &vref = v;
|
||||
@@ -39,7 +39,7 @@ struct X {
|
||||
template <typename T> void g() {
|
||||
std::vector<int> v;
|
||||
std::vector<int>(v).swap(v);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
|
||||
// CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
|
||||
|
||||
std::vector<T> v2;
|
||||
@@ -50,7 +50,7 @@ template <typename T> void g() {
|
||||
template <typename T> void g2() {
|
||||
std::vector<int> v;
|
||||
std::vector<int>(v).swap(v);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
|
||||
// CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
|
||||
|
||||
T v3;
|
||||
@@ -68,7 +68,7 @@ void h() {
|
||||
g2<std::vector<int>>();
|
||||
std::vector<int> v;
|
||||
COPY_AND_SWAP_INT_VEC(v);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
|
||||
// CHECK-FIXES: {{^ }}COPY_AND_SWAP_INT_VEC(v);{{$}}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ struct plus {
|
||||
template <>
|
||||
struct plus<void> {
|
||||
template <typename T, typename U>
|
||||
constexpr auto operator()(T &&Lhs, U &&Rhs) const ->
|
||||
constexpr auto operator()(T &&Lhs, U &&Rhs) const ->
|
||||
decltype(forward<T>(Lhs) + forward<U>(Rhs));
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ void __attribute((ownership_takes(malloc, 1))) my_free(void *);
|
||||
|
||||
void f1() {
|
||||
void *p = malloc(12);
|
||||
return;
|
||||
return;
|
||||
// CHECK: warning: Potential leak of memory pointed to by 'p' [clang-analyzer-unix.Malloc]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user