[PATCH] Fixed UseNullptr causes compile error when replacing return(0);
Ariel Bernal
ariel.j.bernal at intel.com
Tue Mar 5 11:57:06 PST 2013
arielbernal added you to the CC list for the revision "Fixed UseNullptr causes compile error when replacing return(0);".
Hi revane, tareqsiraj,
- Ignored parentheses and implicit cast expressions.
- Added test cases to UseNullptr tests.
this fixes Bug-15398
http://llvm-reviews.chandlerc.com/D496
Files:
cpp11-migrate/UseNullptr/NullptrActions.cpp
test/cpp11-migrate/UseNullptr/basic.cpp
Index: cpp11-migrate/UseNullptr/NullptrActions.cpp
===================================================================
--- cpp11-migrate/UseNullptr/NullptrActions.cpp
+++ cpp11-migrate/UseNullptr/NullptrActions.cpp
@@ -110,8 +110,10 @@
const CastExpr *Cast = Result.Nodes.getNodeAs<CastExpr>(ImplicitCastNode);
if (Cast) {
- SourceLocation StartLoc = Cast->getLocStart();
- SourceLocation EndLoc = Cast->getLocEnd();
+ const Expr *E = Cast->IgnoreParenImpCasts();
+
+ SourceLocation StartLoc = E->getLocStart();
+ SourceLocation EndLoc = E->getLocEnd();
// If the start/end location is a macro, get the expansion location.
StartLoc = SM.getFileLoc(StartLoc);
Index: test/cpp11-migrate/UseNullptr/basic.cpp
===================================================================
--- test/cpp11-migrate/UseNullptr/basic.cpp
+++ test/cpp11-migrate/UseNullptr/basic.cpp
@@ -204,3 +204,19 @@
// CHECK: my_macro(p != nullptr);
#undef my_macro
}
+
+// Test parentheses expressions resulting in a nullptr.
+int *test_parentheses_expression1() {
+ return(0);
+ // CHECK: return(nullptr);
+}
+
+int *test_parentheses_expression2() {
+ return(int(0.f));
+ // CHECK: return(nullptr);
+}
+
+int *test_nested_parentheses_expression() {
+ return((((0))));
+ // CHECK: return((((nullptr))));
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D496.1.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130305/c4f55969/attachment.bin>
More information about the cfe-commits
mailing list