[PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 6 18:38:13 PDT 2016


etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.


This is the same kind of bug that [[ http://reviews.llvm.org/D18238 | D18238 ]].

Fix crashes caused by deferencing null pointer when declarations parsing may be delayed.
The body of the declarations may be null.

The crashes were observed with a Windows build of clang-tidy and the following command-line.
```
command-line switches: -fms-compatibility-version=19 -fms-compatibility
```

http://reviews.llvm.org/D18852

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp

Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===================================================================
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -51,6 +51,10 @@
   bool IsConstQualified =
       Param->getType().getCanonicalType().isConstQualified();
 
+  // Skip declarations delayed by late template parsing without a body.
+  if (!Function->getBody())
+    return;
+
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
   //    misc-move-constructor-init which will suggest to move the argument.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18852.52877.patch
Type: text/x-patch
Size: 683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160407/6db52348/attachment.bin>


More information about the cfe-commits mailing list