[PATCH] D140859: [clang][dataflow] Allow analyzing multiple functions in unit tests

Stanislav Gatev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 00:55:48 PST 2023


sgatev accepted this revision.
sgatev added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp:89-104
+  unsigned FunctionBeginOffset =
+      SourceManager.getFileOffset(Func->getBeginLoc());
+  unsigned FunctionEndOffset = SourceManager.getFileOffset(Func->getEndLoc());
+
   unsigned I = 0;
-  auto Annotations = AnnotatedCode.ranges();
+  std::vector<llvm::Annotations::Range> Annotations = AnnotatedCode.ranges();
+  llvm::erase_if(Annotations, [=](llvm::Annotations::Range R) {
----------------



================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:177
 /// Runs dataflow specified from `AI.MakeAnalysis` and `AI.PostVisitCFG` on the
 /// body of the function that matches `AI.TargetFuncMatcher` in `AI.Code`.
 /// Given the analysis outputs, `VerifyResults` checks that the results from the
----------------
"bodies of all functions that match"


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:269
 /// Runs dataflow specified from `AI.MakeAnalysis` and `AI.PostVisitCFG` on the
 /// body of the function that matches `AI.TargetFuncMatcher` in `AI.Code`. Given
 /// the annotation line numbers and analysis outputs, `VerifyResults` checks
----------------
"bodies of all functions that match"


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:295
 /// Runs dataflow specified from `AI.MakeAnalysis` and `AI.PostVisitCFG` on the
 /// body of the function that matches `AI.TargetFuncMatcher` in `AI.Code`. Given
 /// the state computed at each annotated statement and analysis outputs,
----------------
"bodies of all functions that match"


================
Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:367
         VerifyResults(AnnotationStates, AO);
+        AnnotationStates.clear();
       });
----------------
Can you please add a comment to describe why this needs to be cleared?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140859



More information about the cfe-commits mailing list