NoopAnalysis.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- NoopAnalysis.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 NoopAnalysis class that just uses the builtin transfer.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H
  18. #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H
  19. #include "clang/AST/ASTContext.h"
  20. #include "clang/Analysis/CFG.h"
  21. #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
  22. #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
  23. #include "clang/Analysis/FlowSensitive/NoopLattice.h"
  24. namespace clang {
  25. namespace dataflow {
  26. class NoopAnalysis : public DataflowAnalysis<NoopAnalysis, NoopLattice> {
  27. public:
  28. /// Deprecated. Use the `DataflowAnalysisOptions` constructor instead.
  29. NoopAnalysis(ASTContext &Context, bool ApplyBuiltinTransfer)
  30. : DataflowAnalysis<NoopAnalysis, NoopLattice>(Context,
  31. ApplyBuiltinTransfer) {}
  32. /// `ApplyBuiltinTransfer` controls whether to run the built-in transfer
  33. /// functions that model memory during the analysis. Their results are not
  34. /// used by `NoopAnalysis`, but tests that need to inspect the environment
  35. /// should enable them.
  36. NoopAnalysis(ASTContext &Context, DataflowAnalysisOptions Options)
  37. : DataflowAnalysis<NoopAnalysis, NoopLattice>(Context, Options) {}
  38. static NoopLattice initialElement() { return {}; }
  39. void transfer(const CFGElement *E, NoopLattice &L, Environment &Env) {}
  40. };
  41. } // namespace dataflow
  42. } // namespace clang
  43. #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H
  44. #ifdef __GNUC__
  45. #pragma GCC diagnostic pop
  46. #endif