14#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H
15#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H
19#include "llvm/ADT/DenseMap.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/Debug.h"
24#define DEBUG_TYPE "dataflow"
41 assert(Type.isNull() || !Type->isReferenceType());
97 using FieldToLoc = llvm::DenseMap<const ValueDecl *, StorageLocation *>;
103 SyntheticFields(
std::move(TheSyntheticFields)) {
104 assert(!Type.isNull());
105 assert(Type->isRecordType());
107 for (
auto [Field, Loc] : Children) {
108 if (!Field->getType()->isReferenceType() && Loc ==
nullptr)
127 auto It = Children.find(&D);
129 if (It == Children.end()) {
131 <<
" on StorageLocation " <<
this <<
" of type "
133 llvm::dbgs() <<
"Existing children:\n";
134 for ([[maybe_unused]]
auto [Field, Loc] : Children) {
135 llvm::dbgs() << Field->getNameAsString() <<
"\n";
139 assert(It != Children.end());
147 assert(Loc !=
nullptr);
151 llvm::iterator_range<SyntheticFieldMap::const_iterator>
153 return {SyntheticFields.begin(), SyntheticFields.end()};
158 SyntheticFields.insert({Name, &Loc});
175 Children.insert({&D, Loc});
178 llvm::iterator_range<FieldToLoc::const_iterator>
children()
const {
179 return {Children.begin(), Children.end()};
C Language Family Type Representation.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
A (possibly-)qualified type.
The base class of the type hierarchy.
bool isReferenceType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
llvm::iterator_range< SyntheticFieldMap::const_iterator > synthetic_fields() const
StorageLocation * getChild(const ValueDecl &D) const
Returns the child storage location for D.
llvm::DenseMap< const ValueDecl *, StorageLocation * > FieldToLoc
llvm::StringMap< StorageLocation * > SyntheticFieldMap
RecordStorageLocation(QualType Type, FieldToLoc TheChildren, SyntheticFieldMap TheSyntheticFields)
void setChild(const ValueDecl &D, StorageLocation *Loc)
Changes the child storage location for a field D of reference type.
StorageLocation & getSyntheticField(llvm::StringRef Name) const
Returns the storage location for the synthetic field Name.
void addSyntheticField(llvm::StringRef Name, StorageLocation &Loc)
Add a synthetic field, if none by that name is already present.
void addChild(const ValueDecl &D, StorageLocation *Loc)
Add a child storage location for a field D, if not already present.
static bool classof(const StorageLocation *Loc)
llvm::iterator_range< FieldToLoc::const_iterator > children() const
ScalarStorageLocation(QualType Type)
static bool classof(const StorageLocation *Loc)
virtual ~StorageLocation()=default
StorageLocation(Kind LocKind, QualType Type)
StorageLocation & operator=(const StorageLocation &)=delete
StorageLocation(const StorageLocation &)=delete
The JSON file list parser is used to communicate input to InstallAPI.