diff options
| author | Gabor Horvath <xazax.hun@gmail.com> | 2015-12-15 08:47:20 +0000 |
|---|---|---|
| committer | Gabor Horvath <xazax.hun@gmail.com> | 2015-12-15 08:47:20 +0000 |
| commit | 454564a2d940e28577ef110474b026c568e60f46 (patch) | |
| tree | ce5e40ba1ac16818229d4ad181522d156e6d9951 /clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.h | |
| parent | 6015f5c8237c259ac04c539d55d200baa885a807 (diff) | |
| download | bcm5719-llvm-454564a2d940e28577ef110474b026c568e60f46.tar.gz bcm5719-llvm-454564a2d940e28577ef110474b026c568e60f46.zip | |
[clang-tidy] Check for suspicious string assignments.
It is possible to assign arbitrary integer types to strings.
Sometimes it is the result of missing to_string call or apostrophes.
Reviewers: alexfh
Differential Revision: http://reviews.llvm.org/D15411
llvm-svn: 255630
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.h')
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.h b/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.h new file mode 100644 index 00000000000..072b96aa08e --- /dev/null +++ b/clang-tools-extra/clang-tidy/misc/StringIntegerAssignmentCheck.h @@ -0,0 +1,34 @@ +//===--- StringIntegerAssignmentCheck.h - clang-tidy-------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_INTEGER_ASSIGNMENT_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_INTEGER_ASSIGNMENT_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { + +/// Finds instances where an integer is assigned to a string. +/// +/// For more details see: +/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string-assignment.html +class StringIntegerAssignmentCheck : public ClangTidyCheck { +public: + StringIntegerAssignmentCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_INTEGER_ASSIGNMENT_H + |

