NoopLattice.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- NoopLattice.h -------------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the lattice with exactly one element.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOP_LATTICE_H
  18. #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOP_LATTICE_H
  19. #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
  20. #include <ostream>
  21. namespace clang {
  22. namespace dataflow {
  23. /// Trivial lattice for dataflow analysis with exactly one element.
  24. ///
  25. /// Useful for analyses that only need the Environment and nothing more.
  26. class NoopLattice {
  27. public:
  28. bool operator==(const NoopLattice &Other) const { return true; }
  29. LatticeJoinEffect join(const NoopLattice &Other) {
  30. return LatticeJoinEffect::Unchanged;
  31. }
  32. };
  33. inline std::ostream &operator<<(std::ostream &OS, const NoopLattice &) {
  34. return OS << "noop";
  35. }
  36. } // namespace dataflow
  37. } // namespace clang
  38. #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOP_LATTICE_H
  39. #ifdef __GNUC__
  40. #pragma GCC diagnostic pop
  41. #endif