[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 09:19:01 PDT 2023


tahonermann requested changes to this revision.
tahonermann added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/lib/Lex/PPDirectives.cpp:494
   ++NumSkipped;
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
 
----------------
Perhaps it would make sense to assert `CurLexer` here as well.


================
Comment at: clang/lib/Lex/PPDirectives.cpp:555
       while (true) {
         CurLexer->Lex(Tok);
 
----------------
I don't think this change is sufficient. If `CurLexer` is null, then the `else` branch will be entered and an unconditional dereference occurs there as well. It looks like more analysis is needed, but perhaps the correct fix is to add a non-null assertion somewhere above.


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

https://reviews.llvm.org/D158293



More information about the cfe-commits mailing list