|
|
|||
File indexing completed on 2026-05-10 08:36:21
0001 //===--- UseNodiscardCheck.h - clang-tidy -----------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USENODISCARDCHECK_H 0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USENODISCARDCHECK_H 0011 0012 #include "../ClangTidyCheck.h" 0013 0014 namespace clang::tidy::modernize { 0015 0016 /// Add ``[[nodiscard]]`` to non-void const-member functions with no 0017 /// arguments or pass-by-value or pass by const-reference arguments. 0018 /// \code 0019 /// bool empty() const; 0020 /// bool empty(const Bar &) const; 0021 /// bool empty(int bar) const; 0022 /// \endcode 0023 /// Is converted to: 0024 /// \code 0025 /// [[nodiscard]] bool empty() const; 0026 /// [[nodiscard]] bool empty(const Bar &) const; 0027 /// [[nodiscard]] bool empty(int bar) const; 0028 /// \endcode 0029 /// 0030 /// For the user-facing documentation see: 0031 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-nodiscard.html 0032 class UseNodiscardCheck : public ClangTidyCheck { 0033 public: 0034 UseNodiscardCheck(StringRef Name, ClangTidyContext *Context); 0035 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override; 0036 void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 0037 void registerMatchers(ast_matchers::MatchFinder *Finder) override; 0038 void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 0039 0040 private: 0041 const StringRef NoDiscardMacro; 0042 }; 0043 0044 } // namespace clang::tidy::modernize 0045 0046 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USENODISCARDCHECK_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|