[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 20:04:23 PST 2019


NoQ added a comment.

In D70725#1765981 <https://reviews.llvm.org/D70725#1765981>, @xazax.hun wrote:

> the same call might both acquire and release handles (there are such calls in Fuchsia), so we might end up adding more than one note for a call for which we would need to add more than one transitions


Hmm, would this be too functional?:

  std::vector<std::function> notes;
  for (arg : args) {
    if (isAcquired(param)) {
      State = State->set(arg, Acquired);
      notes.push_back([](Report) {
        if (Report.isInteresting(arg))
          return "Handle acquired here";
      });
    }
    if (isReleased(param)) {
      State = State->set(arg, Released);
      notes.push_back([](Report) {
        if (Report.isInteresting(arg))
          return "Handle released here";
      });
    }
  }
  
  C.addTransition(State, C.getNoteTag(
      // We might as well add a C.getNoteTag() overload
      // to do this automatically.
      [std::move(notes)](Report) {
        for (note : notes)
          note();
      }));

Or, well, yeah, chain the nodes together; you anyway have to do this occasionally due to clumsiness of the rest of the API.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70725





More information about the cfe-commits mailing list