Transfer.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- Transfer.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 a transfer function that evaluates a program statement and
  15. // updates an environment accordingly.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
  19. #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
  20. #include "clang/AST/Stmt.h"
  21. #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
  22. #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
  23. namespace clang {
  24. namespace dataflow {
  25. /// Maps statements to the environments of basic blocks that contain them.
  26. class StmtToEnvMap {
  27. public:
  28. virtual ~StmtToEnvMap() = default;
  29. /// Returns the environment of the basic block that contains `S` or nullptr if
  30. /// there isn't one.
  31. /// FIXME: Ensure that the result can't be null and return a const reference.
  32. virtual const Environment *getEnvironment(const Stmt &S) const = 0;
  33. };
  34. /// Evaluates `S` and updates `Env` accordingly.
  35. ///
  36. /// Requirements:
  37. ///
  38. /// `S` must not be `ParenExpr` or `ExprWithCleanups`.
  39. void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env);
  40. } // namespace dataflow
  41. } // namespace clang
  42. #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
  43. #ifdef __GNUC__
  44. #pragma GCC diagnostic pop
  45. #endif