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.


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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to