[all-commits] [llvm/llvm-project] 1d75b1: [analyzer][NFC] Fix dangling StringRef in barely u...

DonatNagyE via All-commits all-commits at lists.llvm.org
Fri Jun 30 08:18:01 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1d75b18843fbca52655e240a120b5fdeeef17c0e
      https://github.com/llvm/llvm-project/commit/1d75b18843fbca52655e240a120b5fdeeef17c0e
  Author: DonĂ¡t Nagy <donat.nagy at ericsson.com>
  Date:   2023-06-30 (Fri, 30 Jun 2023)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h

  Log Message:
  -----------
  [analyzer][NFC] Fix dangling StringRef in barely used code

CheckerContext::getNoteTag has a shorthand version that takes a
plain 'StringRef Note' instead of a lambda that calculates the note.

The old implementation of this method was incorrect because it created a
lambda that captured the StringRef, which was dereferenced much later,
when the NoteTags were visited.

In the current codebase this does not cause errors because this method
is called only once, and there the `Note` argument is a string literal
that remains valid. However, I tried to use this method in a checker
that I was prototyping, and there it printed random memory junk (instead
of the message that I composed in a local variable).

Differential Revision: https://reviews.llvm.org/D153889




More information about the All-commits mailing list