[PATCH] D150895: [NFC][CLANG] Fix dereference issue before null check found by Coverity static analyzer tool

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 18 12:20:46 PDT 2023


Manna updated this revision to Diff 523502.
Manna added a comment.
Herald added a subscriber: asb.

I have removed `IntrinsicClass`  and updated patch.


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

https://reviews.llvm.org/D150895

Files:
  clang/lib/Parse/ParsePragma.cpp


Index: clang/lib/Parse/ParsePragma.cpp
===================================================================
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -4041,7 +4041,6 @@
 
   PP.Lex(Tok);
   II = Tok.getIdentifierInfo();
-  StringRef IntrinsicClass = II->getName();
   if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
     PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
         << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
@@ -4049,15 +4048,15 @@
     return;
   }
 
+  if (II->isStr("vector"))
+    Actions.DeclareRISCVVBuiltins = true;
+  else if (II->isStr("sifive_vector"))
+    Actions.DeclareRISCVVectorBuiltins = true;
+
   PP.Lex(Tok);
   if (Tok.isNot(tok::eod)) {
     PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
         << "clang riscv intrinsic";
     return;
   }
-
-  if (IntrinsicClass == "vector")
-    Actions.DeclareRISCVVBuiltins = true;
-  else if (IntrinsicClass == "sifive_vector")
-    Actions.DeclareRISCVVectorBuiltins = true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150895.523502.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230518/0d5d0611/attachment-0001.bin>


More information about the cfe-commits mailing list