You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
change-namespace
clang-apply-replacements
clang-move
clang-query
clang-reorder-fields
clang-tidy
clang-tidy-vs
clangd
docs
include-fixer
modularize
pp-trace
test
Unit
change-namespace
clang-apply-replacements
clang-move
clang-query
clang-reorder-fields
clang-tidy
Inputs
android-cloexec-accept.cpp
android-cloexec-accept4.cpp
android-cloexec-creat.cpp
android-cloexec-dup.cpp
android-cloexec-epoll-create.cpp
android-cloexec-epoll-create1.cpp
android-cloexec-fopen.cpp
android-cloexec-inotify-init.cpp
android-cloexec-inotify-init1.cpp
android-cloexec-memfd-create.cpp
android-cloexec-open.cpp
android-cloexec-socket.cpp
basic.cpp
boost-use-to-string.cpp
bugprone-argument-comment-gmock.cpp
bugprone-argument-comment-strict.cpp
bugprone-argument-comment.cpp
bugprone-assert-side-effect.cpp
bugprone-bool-pointer-implicit-conversion.cpp
bugprone-copy-constructor-init.cpp
bugprone-dangling-handle.cpp
bugprone-fold-init-type.cpp
bugprone-forward-declaration-namespace.cpp
bugprone-inaccurate-erase.cpp
bugprone-integer-division.cpp
bugprone-misplaced-operator-in-strlen-in-alloc.c
bugprone-misplaced-operator-in-strlen-in-alloc.cpp
bugprone-move-forwarding-reference.cpp
bugprone-multiple-statement-macro.cpp
bugprone-string-constructor.cpp
bugprone-suspicious-memset-usage.cpp
bugprone-undefined-memory-manipulation.cpp
bugprone-use-after-move.cpp
bugprone-virtual-near-miss.cpp
cert-dcl21-cpp.cpp
cert-dcl58-cpp.cpp
cert-env33-c.c
cert-err34-c.c
cert-err34-c.cpp
cert-flp30-c.c
cert-limited-randomness.c
cert-limited-randomness.cpp
cert-oop11-cpp.cpp
cert-setlongjmp.cpp
cert-static-object-exception.cpp
cert-throw-exception-type.cpp
cert-variadic-function-def.cpp
check_clang_tidy.py
clang-tidy-diff.cpp
clang-tidy-run-with-database.cpp
clean-up-code.cpp
config-files.cpp
cppcoreguidelines-interfaces-global-init.cpp
cppcoreguidelines-no-malloc-custom.cpp
cppcoreguidelines-no-malloc-no-functions.cpp
cppcoreguidelines-no-malloc.cpp
cppcoreguidelines-owning-memory-containers.cpp
cppcoreguidelines-owning-memory-legacy-functions.cpp
cppcoreguidelines-owning-memory.cpp
cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
cppcoreguidelines-pro-bounds-constant-array-index.cpp
cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
cppcoreguidelines-pro-type-const-cast.cpp
cppcoreguidelines-pro-type-cstyle-cast.cpp
cppcoreguidelines-pro-type-member-init-cxx98.cpp
cppcoreguidelines-pro-type-member-init-delayed.cpp
cppcoreguidelines-pro-type-member-init.cpp
cppcoreguidelines-pro-type-reinterpret-cast.cpp
cppcoreguidelines-pro-type-static-cast-downcast.cpp
cppcoreguidelines-pro-type-union-access.cpp
cppcoreguidelines-pro-type-vararg.cpp
cppcoreguidelines-slicing.cpp
cppcoreguidelines-special-member-functions-cxx-03.cpp
cppcoreguidelines-special-member-functions-relaxed.cpp
cppcoreguidelines-special-member-functions.cpp
custom-diagnostics.cpp
deduplication.cpp
diagnostic.cpp
explain-checks.cpp
extra-args.cpp
file-filter.cpp
fix-errors.cpp
fix.cpp
fuchsia-default-arguments.cpp
fuchsia-overloaded-operator.cpp
fuchsia-virtual-inheritance.cpp
google-build-explicit-make-pair.cpp
google-default-arguments.cpp
google-explicit-constructor.cpp
google-module.cpp
google-namespaces.cpp
google-objc-avoid-throwing-exception.m
google-objc-global-variable-declaration.m
google-overloaded-unary-and.cpp
google-readability-casting.c
google-readability-casting.cpp
google-readability-namespace-comments.cpp
google-readability-todo.cpp
google-runtime-int-std.cpp
google-runtime-int.c
google-runtime-int.cpp
google-runtime-member-string-references.cpp
google-runtime-references.cpp
hicpp-exception-baseclass.cpp
hicpp-no-assembler-msvc.cpp
hicpp-no-assembler.cpp
hicpp-signed-bitwise-bug34747.cpp
hicpp-signed-bitwise-standard-types.cpp
hicpp-signed-bitwise-standard-types.h
hicpp-signed-bitwise.cpp
line-filter.cpp
list-checks.cpp
llvm-include-order.cpp
llvm-twine-local.cpp
macros.cpp
misc-definitions-in-headers-1z.hpp
misc-definitions-in-headers.hpp
misc-forwarding-reference-overload.cpp
misc-incorrect-roundings.cpp
misc-lambda-function-name.cpp
misc-macro-parentheses-cmdline.cpp
misc-macro-parentheses.cpp
misc-macro-repeated-side-effects.c
misc-misplaced-const.c
misc-misplaced-const.cpp
misc-misplaced-widening-cast-explicit-only.cpp
misc-misplaced-widening-cast-implicit-enabled.cpp
misc-new-delete-overloads-sized-dealloc.cpp
misc-new-delete-overloads.cpp
misc-non-copyable-objects.c
misc-non-copyable-objects.cpp
misc-redundant-expression.cpp
misc-sizeof-container.cpp
misc-sizeof-expression.cpp
misc-static-assert.c
misc-static-assert.cpp
misc-string-compare.cpp
misc-string-integer-assignment.cpp
misc-string-literal-with-embedded-nul.cpp
misc-suspicious-enum-usage-strict.cpp
misc-suspicious-enum-usage.cpp
misc-suspicious-missing-comma.cpp
misc-suspicious-semicolon-fail.cpp
misc-suspicious-semicolon.cpp
misc-suspicious-string-compare.c
misc-suspicious-string-compare.cpp
misc-swapped-arguments.cpp
misc-throw-by-value-catch-by-reference.cpp
misc-unconventional-assign-operator.cpp
misc-undelegated-constructor-cxx98.cpp
misc-undelegated-constructor.cpp
misc-uniqueptr-reset-release.cpp
misc-unused-alias-decls.cpp
misc-unused-parameters.c
misc-unused-parameters.cpp
misc-unused-raii.cpp
misc-unused-using-decls-errors.cpp
misc-unused-using-decls.cpp
modernize-avoid-bind.cpp
modernize-deprecated-headers-cxx03.cpp
modernize-deprecated-headers-cxx11.cpp
modernize-loop-convert-assert-failure.cpp
modernize-loop-convert-basic.cpp
modernize-loop-convert-camelback.cpp
modernize-loop-convert-const.cpp
modernize-loop-convert-extra.cpp
modernize-loop-convert-lowercase.cpp
modernize-loop-convert-negative.cpp
modernize-loop-convert-uppercase.cpp
modernize-loop-convert.c
modernize-make-shared-header.cpp
modernize-make-shared.cpp
modernize-make-unique-header.cpp
modernize-make-unique-macros.cpp
modernize-make-unique.cpp
modernize-pass-by-value-header.cpp
modernize-pass-by-value-macro-header.cpp
modernize-pass-by-value-multi-fixes.cpp
modernize-pass-by-value.cpp
modernize-raw-string-literal-delimiter.cpp
modernize-raw-string-literal-replace-shorter.cpp
modernize-raw-string-literal.cpp
modernize-redundant-void-arg-delayed.cpp
modernize-redundant-void-arg.c
modernize-redundant-void-arg.cpp
modernize-replace-auto-ptr.cpp
modernize-replace-random-shuffle.cpp
modernize-return-braced-init-list.cpp
modernize-shrink-to-fit.cpp
modernize-unary-static-assert.cpp
modernize-use-auto-cast-remove-stars.cpp
modernize-use-auto-cast.cpp
modernize-use-auto-iterator.cpp
modernize-use-auto-new-remove-stars.cpp
modernize-use-auto-new.cpp
modernize-use-bool-literals-ignore-macros.cpp
modernize-use-bool-literals.cpp
modernize-use-default-member-init-assignment.cpp
modernize-use-default-member-init-macros.cpp
modernize-use-default-member-init.cpp
modernize-use-emplace-ignore-implicit-constructors.cpp
modernize-use-emplace.cpp
modernize-use-equals-default-copy.cpp
modernize-use-equals-default-delayed.cpp
modernize-use-equals-default-macros.cpp
modernize-use-equals-default.cpp
modernize-use-equals-delete.cpp
modernize-use-noexcept-macro.cpp
modernize-use-noexcept-opt.cpp
modernize-use-noexcept.cpp
modernize-use-nullptr-basic.cpp
modernize-use-nullptr.c
modernize-use-nullptr.cpp
modernize-use-override-cxx98.cpp
modernize-use-override-ms.cpp
modernize-use-override.cpp
modernize-use-transparent-functors.cpp
modernize-use-using-macros.cpp
modernize-use-using.cpp
mpi-buffer-deref.cpp
mpi-type-mismatch.cpp
nolint.cpp
nolintnextline.cpp
nonstandard-file-extension.test
objc-arc-and-properties.m
objc-avoid-nserror-init.m
objc-avoid-spinlock.m
objc-forbidden-subclassing-custom.m
objc-forbidden-subclassing.m
objc-no-arc-or-properties.m
objc-property-declaration-custom.m
objc-property-declaration.m
overlapping.cpp
performance-faster-string-find.cpp
performance-for-range-copy-warn-on-all-auto-copies.cpp
performance-for-range-copy.cpp
performance-implicit-conversion-in-loop.cpp
performance-inefficient-algorithm.cpp
performance-inefficient-string-concatenation.cpp
performance-inefficient-vector-operation.cpp
performance-move-const-arg-trivially-copyable.cpp
performance-move-const-arg.cpp
performance-move-constructor-init.cpp
performance-noexcept-move-constructor.cpp
performance-type-promotion-in-math-fn.cpp
performance-unnecessary-copy-initialization.cpp
performance-unnecessary-value-param-delayed.cpp
performance-unnecessary-value-param-header.cpp
performance-unnecessary-value-param-incomplete-type.cpp
performance-unnecessary-value-param.cpp
readability-avoid-const-params-in-decls.cpp
readability-braces-around-statements-assert-failure.cpp
readability-braces-around-statements-few-lines.cpp
readability-braces-around-statements-format.cpp
readability-braces-around-statements-same-line.cpp
readability-braces-around-statements-single-line.cpp
readability-braces-around-statements.cpp
readability-container-size-empty.cpp
readability-delete-null-pointer.cpp
readability-deleted-default.cpp
readability-else-after-return.cpp
readability-function-size.cpp
readability-identifier-naming.cpp
readability-implicit-bool-conversion-allow-in-conditions.cpp
readability-implicit-bool-conversion-cxx98.cpp
readability-implicit-bool-conversion.cpp
readability-inconsistent-declaration-parameter-name.cpp
readability-misleading-indentation.cpp
readability-misplaced-array-index.cpp
readability-named-parameter.cpp
readability-non-const-parameter.cpp
readability-redundant-control-flow.cpp
readability-redundant-declaration-ignore-macros.cpp
readability-redundant-declaration.cpp
readability-redundant-function-ptr-dereference.cpp
readability-redundant-member-init.cpp
readability-redundant-smartptr-get.cpp
readability-redundant-string-cstr-msvc.cpp
readability-redundant-string-cstr.cpp
readability-redundant-string-init-msvc.cpp
readability-redundant-string-init.cpp
readability-simplify-bool-expr-chained-conditional-assignment.cpp
readability-simplify-bool-expr-chained-conditional-return.cpp
readability-simplify-bool-expr.cpp
readability-static-accessed-through-instance-nesting-threshold.cpp
readability-static-accessed-through-instance.cpp
readability-static-definition-in-anonymous-namespace.cpp
readability-uniqueptr-delete-release.cpp
select-checks.cpp
serialize-diagnostics.cpp
static-analyzer-config.cpp
static-analyzer.cpp
temporaries.cpp
validate-check-names.cpp
werrors-diagnostics.cpp
werrors-plural.cpp
werrors.cpp
clangd
include-fixer
modularize
pp-trace
.clang-format
CMakeLists.txt
lit.cfg
lit.site.cfg.in
tool-template
unittests
.arcconfig
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
LICENSE.TXT
README.txt
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
338 lines
13 KiB
C++
338 lines
13 KiB
C++
![]() |
// RUN: %check_clang_tidy %s misc-suspicious-string-compare %t -- \
|
||
|
// RUN: -config='{CheckOptions: \
|
||
|
// RUN: [{key: misc-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \
|
||
|
// RUN: {key: misc-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \
|
||
|
// RUN: --
|
||
|
|
||
|
typedef __SIZE_TYPE__ size;
|
||
|
|
||
|
struct locale_t {
|
||
|
void* dummy;
|
||
|
} locale;
|
||
|
|
||
|
static const char A[] = "abc";
|
||
|
static const unsigned char U[] = "abc";
|
||
|
static const unsigned char V[] = "xyz";
|
||
|
static const wchar_t W[] = L"abc";
|
||
|
|
||
|
int strlen(const char *);
|
||
|
|
||
|
int memcmp(const void *, const void *, size);
|
||
|
int wmemcmp(const wchar_t *, const wchar_t *, size);
|
||
|
int memicmp(const void *, const void *, size);
|
||
|
int _memicmp(const void *, const void *, size);
|
||
|
int _memicmp_l(const void *, const void *, size, locale_t);
|
||
|
|
||
|
int strcmp(const char *, const char *);
|
||
|
int strncmp(const char *, const char *, size);
|
||
|
int strcasecmp(const char *, const char *);
|
||
|
int strncasecmp(const char *, const char *, size);
|
||
|
int stricmp(const char *, const char *);
|
||
|
int strcmpi(const char *, const char *);
|
||
|
int strnicmp(const char *, const char *, size);
|
||
|
int _stricmp(const char *, const char * );
|
||
|
int _strnicmp(const char *, const char *, size);
|
||
|
int _stricmp_l(const char *, const char *, locale_t);
|
||
|
int _strnicmp_l(const char *, const char *, size, locale_t);
|
||
|
|
||
|
int wcscmp(const wchar_t *, const wchar_t *);
|
||
|
int wcsncmp(const wchar_t *, const wchar_t *, size);
|
||
|
int wcscasecmp(const wchar_t *, const wchar_t *);
|
||
|
int wcsicmp(const wchar_t *, const wchar_t *);
|
||
|
int wcsnicmp(const wchar_t *, const wchar_t *, size);
|
||
|
int _wcsicmp(const wchar_t *, const wchar_t *);
|
||
|
int _wcsnicmp(const wchar_t *, const wchar_t *, size);
|
||
|
int _wcsicmp_l(const wchar_t *, const wchar_t *, locale_t);
|
||
|
int _wcsnicmp_l(const wchar_t *, const wchar_t *, size, locale_t);
|
||
|
|
||
|
int _mbscmp(const unsigned char *, const unsigned char *);
|
||
|
int _mbsncmp(const unsigned char *, const unsigned char *, size);
|
||
|
int _mbsnbcmp(const unsigned char *, const unsigned char *, size);
|
||
|
int _mbsnbicmp(const unsigned char *, const unsigned char *, size);
|
||
|
int _mbsicmp(const unsigned char *, const unsigned char *);
|
||
|
int _mbsnicmp(const unsigned char *, const unsigned char *, size);
|
||
|
int _mbscmp_l(const unsigned char *, const unsigned char *, locale_t);
|
||
|
int _mbsncmp_l(const unsigned char *, const unsigned char *, size, locale_t);
|
||
|
int _mbsicmp_l(const unsigned char *, const unsigned char *, locale_t);
|
||
|
int _mbsnicmp_l(const unsigned char *, const unsigned char *, size, locale_t);
|
||
|
int _mbsnbcmp_l(const unsigned char *, const unsigned char *, size, locale_t);
|
||
|
int _mbsnbicmp_l(const unsigned char *, const unsigned char *, size, locale_t);
|
||
|
|
||
|
int test_warning_patterns() {
|
||
|
if (strcmp(A, "a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [misc-suspicious-string-compare]
|
||
|
// CHECK-FIXES: if (strcmp(A, "a") != 0)
|
||
|
|
||
|
if (strcmp(A, "a") == 0 ||
|
||
|
strcmp(A, "b"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strcmp(A, "b") != 0)
|
||
|
|
||
|
if (strcmp(A, "a") == 1)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
|
||
|
|
||
|
if (strcmp(A, "a") == -1)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
|
||
|
|
||
|
if (strcmp(A, "a") == true)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
|
||
|
|
||
|
if (strcmp(A, "a") < '0')
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
|
||
|
|
||
|
if (strcmp(A, "a") < 0.)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' has suspicious implicit cast
|
||
|
}
|
||
|
|
||
|
int test_valid_patterns() {
|
||
|
// The following cases are valid.
|
||
|
if (strcmp(A, "a") < 0)
|
||
|
return 0;
|
||
|
if (strcmp(A, "a") == 0)
|
||
|
return 0;
|
||
|
if (strcmp(A, "a") <= 0)
|
||
|
return 0;
|
||
|
|
||
|
if (wcscmp(W, L"a") < 0)
|
||
|
return 0;
|
||
|
if (wcscmp(W, L"a") == 0)
|
||
|
return 0;
|
||
|
if (wcscmp(W, L"a") <= 0)
|
||
|
return 0;
|
||
|
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
int test_implicit_compare_with_functions() {
|
||
|
|
||
|
if (memcmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memcmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: memcmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (wmemcmp(W, L"a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wmemcmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: wmemcmp(W, L"a", 1) != 0)
|
||
|
|
||
|
if (memicmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: memicmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (_memicmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _memicmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (_memicmp_l(A, "a", 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _memicmp_l(A, "a", 1, locale) != 0)
|
||
|
|
||
|
if (strcmp(A, "a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strcmp(A, "a") != 0)
|
||
|
|
||
|
if (strncmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strncmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (strcasecmp(A, "a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcasecmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strcasecmp(A, "a") != 0)
|
||
|
|
||
|
if (strncasecmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncasecmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strncasecmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (stricmp(A, "a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'stricmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: stricmp(A, "a") != 0)
|
||
|
|
||
|
if (strcmpi(A, "a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmpi' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strcmpi(A, "a") != 0)
|
||
|
|
||
|
if (_stricmp(A, "a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _stricmp(A, "a") != 0)
|
||
|
|
||
|
if (strnicmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strnicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: strnicmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (_strnicmp(A, "a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _strnicmp(A, "a", 1) != 0)
|
||
|
|
||
|
if (_stricmp_l(A, "a", locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _stricmp_l(A, "a", locale) != 0)
|
||
|
|
||
|
if (_strnicmp_l(A, "a", 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _strnicmp_l(A, "a", 1, locale) != 0)
|
||
|
|
||
|
if (wcscmp(W, L"a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: wcscmp(W, L"a") != 0)
|
||
|
|
||
|
if (wcsncmp(W, L"a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsncmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: wcsncmp(W, L"a", 1) != 0)
|
||
|
|
||
|
if (wcscasecmp(W, L"a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscasecmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: wcscasecmp(W, L"a") != 0)
|
||
|
|
||
|
if (wcsicmp(W, L"a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: wcsicmp(W, L"a") != 0)
|
||
|
|
||
|
if (_wcsicmp(W, L"a"))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _wcsicmp(W, L"a") != 0)
|
||
|
|
||
|
if (_wcsicmp_l(W, L"a", locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _wcsicmp_l(W, L"a", locale) != 0)
|
||
|
|
||
|
if (wcsnicmp(W, L"a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsnicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: wcsnicmp(W, L"a", 1) != 0)
|
||
|
|
||
|
if (_wcsnicmp(W, L"a", 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _wcsnicmp(W, L"a", 1) != 0)
|
||
|
|
||
|
if (_wcsnicmp_l(W, L"a", 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _wcsnicmp_l(W, L"a", 1, locale) != 0)
|
||
|
|
||
|
if (_mbscmp(U, V))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbscmp(U, V) != 0)
|
||
|
|
||
|
if (_mbsncmp(U, V, 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsncmp(U, V, 1) != 0)
|
||
|
|
||
|
if (_mbsnbcmp(U, V, 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsnbcmp(U, V, 1) != 0)
|
||
|
|
||
|
if (_mbsnbicmp(U, V, 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsnbicmp(U, V, 1) != 0)
|
||
|
|
||
|
if (_mbsicmp(U, V))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsicmp(U, V) != 0)
|
||
|
|
||
|
if (_mbsnicmp(U, V, 1))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsnicmp(U, V, 1) != 0)
|
||
|
|
||
|
if (_mbscmp_l(U, V, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbscmp_l(U, V, locale) != 0)
|
||
|
|
||
|
if (_mbsncmp_l(U, V, 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsncmp_l(U, V, 1, locale) != 0)
|
||
|
|
||
|
if (_mbsicmp_l(U, V, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsicmp_l(U, V, locale) != 0)
|
||
|
|
||
|
if (_mbsnicmp_l(U, V, 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsnicmp_l(U, V, 1, locale) != 0)
|
||
|
|
||
|
if (_mbsnbcmp_l(U, V, 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsnbcmp_l(U, V, 1, locale) != 0)
|
||
|
|
||
|
if (_mbsnbicmp_l(U, V, 1, locale))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp_l' is called without explicitly comparing result
|
||
|
// CHECK-FIXES: _mbsnbicmp_l(U, V, 1, locale) != 0)
|
||
|
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
int strcmp_wrapper1(const char* a, const char* b) {
|
||
|
return strcmp(a, b);
|
||
|
}
|
||
|
|
||
|
int strcmp_wrapper2(const char* a, const char* b) {
|
||
|
return (a && b) ? strcmp(a, b) : 0;
|
||
|
}
|
||
|
|
||
|
#define macro_strncmp(s1, s2, n) \
|
||
|
(__extension__ (__builtin_constant_p (n) \
|
||
|
&& ((__builtin_constant_p (s1) \
|
||
|
&& strlen (s1) < ((size) (n))) \
|
||
|
|| (__builtin_constant_p (s2) \
|
||
|
&& strlen (s2) < ((size) (n)))) \
|
||
|
? strcmp (s1, s2) : strncmp (s1, s2, n)))
|
||
|
|
||
|
int strncmp_macro(const char* a, const char* b) {
|
||
|
if (macro_strncmp(a, b, 4))
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
|
||
|
|
||
|
if (macro_strncmp(a, b, 4) == 2)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
|
||
|
|
||
|
if (macro_strncmp(a, b, 4) <= .0)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' has suspicious implicit cast
|
||
|
|
||
|
if (macro_strncmp(a, b, 4) + 0)
|
||
|
return 0;
|
||
|
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: results of function 'strcmp' used by operator '+'
|
||
|
|
||
|
return 1;
|
||
|
}
|