//===-- StorageLocation.h ---------------------------------------*- C++ -*-===// // // 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 // //===----------------------------------------------------------------------===// // // This file defines classes that represent elements of the local variable store // and of the heap during dataflow analysis. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H #include "clang/AST/Decl.h" #include "clang/AST/Type.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Debug.h" #include <cassert> #define DEBUG_TYPE … namespace clang { namespace dataflow { /// Base class for elements of the local variable store and of the heap. /// /// Each storage location holds a value. The mapping from storage locations to /// values is stored in the environment. class StorageLocation { … }; /// A storage location that is not subdivided further for the purposes of /// abstract interpretation. For example: `int`, `int*`, `int&`. class ScalarStorageLocation final : public StorageLocation { … }; /// A storage location for a record (struct, class, or union). /// /// Contains storage locations for all modeled fields of the record (also /// referred to as "children"). The child map is flat, so accessible members of /// the base class are directly accessible as children of this location. /// /// Record storage locations may also contain so-called synthetic fields. These /// are typically used to model the internal state of a class (e.g. the value /// stored in a `std::optional`) without having to depend on that class's /// implementation details. All `RecordStorageLocation`s of a given type should /// have the same synthetic fields. /// /// The storage location for a field of reference type may be null. This /// typically occurs in one of two situations: /// - The record has not been fully initialized. /// - The maximum depth for modelling a self-referential data structure has been /// reached. /// Storage locations for fields of all other types must be non-null. /// /// FIXME: Currently, the storage location of unions is modelled the same way as /// that of structs or classes. Eventually, we need to change this modelling so /// that all of the members of a given union have the same storage location. class RecordStorageLocation final : public StorageLocation { … }; } // namespace dataflow } // namespace clang #undef DEBUG_TYPE #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H