r326230 - [analyzer] Quickfix: don't crash when runtime definition is not available.

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 27 11:19:49 PST 2018


Author: george.karpenkov
Date: Tue Feb 27 11:19:49 2018
New Revision: 326230

URL: http://llvm.org/viewvc/llvm-project?rev=326230&view=rev
Log:
[analyzer] Quickfix: don't crash when runtime definition is not available.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=326230&r1=326229&r2=326230&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Feb 27 11:19:49 2018
@@ -321,9 +321,11 @@ private:
   /// Get parameters associated with runtime definition in order
   /// to get the correct parameter name.
   ArrayRef<ParmVarDecl *> getCallParameters(CallEventRef<> Call) {
-    if (isa<FunctionDecl>(Call->getDecl()))
-      return dyn_cast<FunctionDecl>(Call->getRuntimeDefinition().getDecl())
-          ->parameters();
+    // Use runtime definition, if available.
+    RuntimeDefinition RD = Call->getRuntimeDefinition();
+    if (auto *FD = dyn_cast_or_null<FunctionDecl>(RD.getDecl()))
+      return FD->parameters();
+
     return Call->parameters();
   }
 




More information about the cfe-commits mailing list