[PATCH] D154339: [clang][dataflow] Make `runDataflowReturnError()` a non-template function.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 4 04:14:10 PDT 2023


mboehme added inline comments.


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:389
 /// verify the results.
-template <typename VerifyResultsT>
-llvm::Error
-runDataflowReturnError(llvm::StringRef Code, VerifyResultsT VerifyResults,
-                       DataflowAnalysisOptions Options,
-                       LangStandard::Kind Std = LangStandard::lang_cxx17,
-                       llvm::StringRef TargetFun = "target") {
-  using ast_matchers::hasName;
-  llvm::SmallVector<std::string, 3> ASTBuildArgs = {
-      // -fnodelayed-template-parsing is the default everywhere but on Windows.
-      // Set it explicitly so that tests behave the same on Windows as on other
-      // platforms.
-      "-fsyntax-only", "-fno-delayed-template-parsing",
-      "-std=" +
-          std::string(LangStandard::getLangStandardForKind(Std).getName())};
-  AnalysisInputs<NoopAnalysis> AI(
-      Code, hasName(TargetFun),
-      [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext &C,
-                                                          Environment &Env) {
-        return NoopAnalysis(
-            C,
-            DataflowAnalysisOptions{
-                UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
-                                : std::optional<BuiltinOptions>()});
-      });
-  AI.ASTBuildArgs = ASTBuildArgs;
-  if (Options.BuiltinOpts)
-    AI.BuiltinOptions = *Options.BuiltinOpts;
-  return checkDataflow<NoopAnalysis>(
-      std::move(AI),
-      /*VerifyResults=*/
-      [&VerifyResults](
-          const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
-          const AnalysisOutputs &AO) { VerifyResults(Results, AO.ASTCtx); });
-}
+llvm::Error runDataflowReturnError(
+    llvm::StringRef Code,
----------------
gribozavr2 wrote:
> I don't quite understand your comment from the previous patch:
> 
> > This is really just moved from TransferTest.cpp -- and it's more closely related to the `runDataflow()` functions there and in the newly added RecordOps.cpp. (I can't call it `runDataflow()` because then it would differ only in return type from one of the functions in the overload set.)
> 
> I don't see another `checkDataflow()` function with the same signature. Furthermore, `checkDataflow()` overloads above already return an `llvm::Error`.
What I meant is: This function seemed to me to be more closely related to the `runDataflow()` functions in TransferTest.cpp than to the `checkDataflow()` functions above -- because of the parameter types (the `checkDataflow()` functions take `AnalysisInputs`, while this this function doesn't), and also because this function, like the `runDataflow()` functions, is not a template, while the `checkDataflow()` functions are.

Should I ignore these superficial similarities?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154339/new/

https://reviews.llvm.org/D154339



More information about the cfe-commits mailing list