Reported by Coverity static analyzer tool:
Inside "ParsePragma.cpp" file, in <unnamed>::PragmaRISCVHandler::HandlePragma(clang::Preprocessor &, clang::PragmaIntroducer, clang::Token &): All paths that lead to this null pointer comparison already dereference the pointer earlier PP.Lex(Tok); II = Tok.getIdentifierInfo(); //deref_ptr_in_call: Dereferencing pointer II. StringRef IntrinsicClass = II->getName(); //Dereference before null check (REVERSE_INULL) //check_after_deref: Null-checking II suggests that it may be null, but it has already been dereferenced on all paths leading to the check. if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) { PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument) << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true << "'vector' or 'sifive_vector'"; return; }
This patch moves the line StringRef IntrinsicClass = II->getName() after null checking II
I think you still need line 4043 here, right? The one where II is set to the Token?