[AMDGPU][AsmParser][NFC] Translate parsed MIMG instructions to MCInsts automatically.
[llvm-project.git] / clang-tools-extra / clang-tidy / cppcoreguidelines / OwningMemoryCheck.h
blob4dd2f569d0f2e2f7968052dbabc3ae74d554e831
1 //===--- OwningMemoryCheck.h - clang-tidy------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_OWNING_MEMORY_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_OWNING_MEMORY_H
12 #include "../ClangTidyCheck.h"
14 namespace clang::tidy::cppcoreguidelines {
16 /// Checks for common use cases for gsl::owner and enforces the unique owner
17 /// nature of it whenever possible.
18 ///
19 /// For the user-facing documentation see:
20 /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/owning-memory.html
21 class OwningMemoryCheck : public ClangTidyCheck {
22 public:
23 OwningMemoryCheck(StringRef Name, ClangTidyContext *Context)
24 : ClangTidyCheck(Name, Context),
25 LegacyResourceProducers(Options.get(
26 "LegacyResourceProducers", "::malloc;::aligned_alloc;::realloc;"
27 "::calloc;::fopen;::freopen;::tmpfile")),
28 LegacyResourceConsumers(Options.get(
29 "LegacyResourceConsumers", "::free;::realloc;::freopen;::fclose")) {
31 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
32 return LangOpts.CPlusPlus11;
35 /// Make configuration of checker discoverable.
36 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
38 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
39 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
41 private:
42 bool handleDeletion(const ast_matchers::BoundNodes &Nodes);
43 bool handleLegacyConsumers(const ast_matchers::BoundNodes &Nodes);
44 bool handleExpectedOwner(const ast_matchers::BoundNodes &Nodes);
45 bool handleAssignmentAndInit(const ast_matchers::BoundNodes &Nodes);
46 bool handleAssignmentFromNewOwner(const ast_matchers::BoundNodes &Nodes);
47 bool handleReturnValues(const ast_matchers::BoundNodes &Nodes);
48 bool handleOwnerMembers(const ast_matchers::BoundNodes &Nodes);
50 /// List of old C-style functions that create resources.
51 /// Defaults to
52 /// `::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile`.
53 const StringRef LegacyResourceProducers;
54 /// List of old C-style functions that consume or release resources.
55 /// Defaults to `::free;::realloc;::freopen;::fclose`.
56 const StringRef LegacyResourceConsumers;
59 } // namespace clang::tidy::cppcoreguidelines
61 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_OWNING_MEMORY_H