2015-02-10 17:14:26 +08:00
|
|
|
//===--- InaccurateEraseCheck.h - clang-tidy---------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-02-10 17:14:26 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-11-24 22:16:29 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INACCURATEERASECHECK_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INACCURATEERASECHECK_H
|
2015-02-10 17:14:26 +08:00
|
|
|
|
2019-03-25 20:38:26 +08:00
|
|
|
#include "../ClangTidyCheck.h"
|
2015-02-10 17:14:26 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
2017-11-24 22:16:29 +08:00
|
|
|
namespace bugprone {
|
2015-02-10 17:14:26 +08:00
|
|
|
|
2015-08-28 02:01:58 +08:00
|
|
|
/// Checks for inaccurate use of the `erase()` method.
|
2015-02-10 17:14:26 +08:00
|
|
|
///
|
2015-08-28 02:01:58 +08:00
|
|
|
/// Algorithms like `remove()` do not actually remove any element from the
|
2015-02-10 17:14:26 +08:00
|
|
|
/// container but return an iterator to the first redundant element at the end
|
|
|
|
/// of the container. These redundant elements must be removed using the
|
2015-08-28 02:01:58 +08:00
|
|
|
/// `erase()` method. This check warns when not all of the elements will be
|
2015-02-10 17:14:26 +08:00
|
|
|
/// removed due to using an inappropriate overload.
|
|
|
|
class InaccurateEraseCheck : public ClangTidyCheck {
|
|
|
|
public:
|
|
|
|
InaccurateEraseCheck(StringRef Name, ClangTidyContext *Context)
|
|
|
|
: ClangTidyCheck(Name, Context) {}
|
|
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
|
|
};
|
|
|
|
|
2017-11-24 22:16:29 +08:00
|
|
|
} // namespace bugprone
|
2015-02-10 17:14:26 +08:00
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|
|
|
|
|
2017-11-24 22:16:29 +08:00
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INACCURATEERASECHECK_H
|