Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /main /. /tools /clang /plugins /StackAllocatedChecker.h
blob: 7ee0170ffc56cd8450b9677dd554e465c333104f [file] [log] [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TOOLS_CLANG_PLUGINS_STACKALLOCATEDCHECKER_H_
#define TOOLS_CLANG_PLUGINS_STACKALLOCATEDCHECKER_H_
#include<map>
namespace clang{
classCompilerInstance;
classCXXRecordDecl;
classFieldDecl;
}// namespace clang
namespace chrome_checker{
// This determines a record (class/struct) is annotated with
// |STACK_ALLOCATED()|. Even if it is explicitly annotated with
// |STACK_ALLOCATED()|, this will consider it as "stack allocated" when its
// ancestor has the annotation. Similarly, classes with a "stack allocated"
// template type parameter is considered "stack allocated".
classStackAllocatedPredicate{
public:
boolIsStackAllocated(const clang::CXXRecordDecl* record)const;
private:
mutable std::map<const clang::CXXRecordDecl*,bool> cache_;
};
// This verifies usage of classes annotated with STACK_ALLOCATED().
// Specifically, it ensures that an instance of such a class cannot be used as a
// member variable in a non-STACK_ALLOCATED() class.
classStackAllocatedChecker{
public:
explicitStackAllocatedChecker(clang::CompilerInstance& compiler);
voidCheck(clang::CXXRecordDecl* record);
private:
clang::CompilerInstance& compiler_;
unsigned stack_allocated_field_error_signature_;
StackAllocatedPredicate predicate_;
};
}// namespace chrome_checker
#endif// TOOLS_CLANG_PLUGINS_STACKALLOCATEDCHECKER_H_

[8]ページ先頭

©2009-2025 Movatter.jp