llvm/clang/include/clang/Analysis/FlowSensitive/MapLattice.h

//===------------------------ MapLattice.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 a parameterized lattice that maps keys to individual
//  lattice elements (of the parameter lattice type). A typical usage is lifting
//  a particular lattice to all variables in a lexical scope.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__MAPLATTICE_H
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__MAPLATTICE_H

#include <ostream>
#include <string>
#include <utility>

#include "DataflowAnalysis.h"
#include "clang/AST/Decl.h"
#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"

namespace clang {
namespace dataflow {

/// A lattice that maps keys to individual lattice elements. When instantiated
/// with an `ElementLattice` that is a bounded semi-lattice, `MapLattice` is
/// itself a bounded semi-lattice, so long as the user limits themselves to a
/// finite number of keys. In that case, `top` is (implicitly), the map
/// containing all valid keys mapped to `top` of `ElementLattice`.
///
/// Requirements on `ElementLattice`:
/// * Provides standard declarations of a bounded semi-lattice.
template <typename Key, typename ElementLattice> class MapLattice {};

/// Convenience alias that captures the common use of map lattices to model
/// in-scope variables.
VarMapLattice;

template <typename Key, typename ElementLattice>
std::ostream &
operator<<(std::ostream &Os,
           const clang::dataflow::MapLattice<Key, ElementLattice> &M) {}

template <typename ElementLattice>
std::ostream &
operator<<(std::ostream &Os,
           const clang::dataflow::VarMapLattice<ElementLattice> &M) {}
} // namespace dataflow
} // namespace clang

#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__MAPLATTICE_H