diff options
author | Sam Estep <sam@samestep.com> | 2022-07-22 14:10:15 +0000 |
---|---|---|
committer | Sam Estep <sam@samestep.com> | 2022-07-22 14:11:32 +0000 |
commit | 32dcb759c3005d8395b411a9aaa3d90815661d1c (patch) | |
tree | 90a73879b30ebe809c9e0e069b084d885ecf7b9e /clang/include | |
parent | c2be703c6cd4262699a6255e8b5e4331f949e10b (diff) | |
download | llvm-32dcb759c3005d8395b411a9aaa3d90815661d1c.zip llvm-32dcb759c3005d8395b411a9aaa3d90815661d1c.tar.gz llvm-32dcb759c3005d8395b411a9aaa3d90815661d1c.tar.bz2 |
[clang][dataflow] Move NoopAnalysis from unittests to include
This patch moves `Analysis/FlowSensitive/NoopAnalysis.h` from `clang/unittests/` to `clang/include/clang/`, so that we can use it for doing context-sensitive analysis.
Reviewed By: ymandel, gribozavr2, sgatev
Differential Revision: https://reviews.llvm.org/D130304
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h new file mode 100644 index 0000000..15b7221 --- /dev/null +++ b/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h @@ -0,0 +1,43 @@ +//===-- NoopAnalysis.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 NoopAnalysis class that just uses the builtin transfer. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H +#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H + +#include "clang/AST/ASTContext.h" +#include "clang/AST/Stmt.h" +#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h" +#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" +#include "clang/Analysis/FlowSensitive/NoopLattice.h" + +namespace clang { +namespace dataflow { + +class NoopAnalysis : public DataflowAnalysis<NoopAnalysis, NoopLattice> { +public: + /// `ApplyBuiltinTransfer` controls whether to run the built-in transfer + /// functions that model memory during the analysis. Their results are not + /// used by `NoopAnalysis`, but tests that need to inspect the environment + /// should enable them. + NoopAnalysis(ASTContext &Context, bool ApplyBuiltinTransfer) + : DataflowAnalysis<NoopAnalysis, NoopLattice>(Context, + ApplyBuiltinTransfer) {} + + static NoopLattice initialElement() { return {}; } + + void transfer(const Stmt *S, NoopLattice &E, Environment &Env) {} +}; + +} // namespace dataflow +} // namespace clang + +#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H |