[PATCH] D60055: Check i < FD->getNumParams() before querying

Violet via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 8 09:04:19 PDT 2019


Violet marked 2 inline comments as done.
Violet added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2895
       // function and isn't necessarily referring to one of FD's parameters.
-      if (FD->getParamDecl(i) == PV)
+      if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
         return FD->getCanonicalDecl()->getParamDecl(i);
----------------
lebedev.ri wrote:
> Have you analyzed how we get here?
> Maybe the caller code is faulty?
It's not the caller's fault. The cause is that a function pointer or a function typedef isn't a declcontext, so even if the getDeclContext() of its parameter returns a function, it has nothing to do with its own ParmVarDecl. That's why we check if the corresponding ParmVarDecl is the same one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60055





More information about the cfe-commits mailing list