Address feedback from Eli Friedman on r166522.

In particular, we do want to warn on some unused cast subexpressions within
macros.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166534 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 68bce4b..6f4c8e2 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -2026,10 +2026,6 @@
   }
   case CXXFunctionalCastExprClass:
   case CStyleCastExprClass: {
-    // Ignore casts within macro expansions.
-    if (getExprLoc().isMacroID())
-      return false;
-
     // Ignore an explicit cast to void unless the operand is a non-trivial
     // volatile lvalue.
     const CastExpr *CE = cast<CastExpr>(this);
@@ -2047,6 +2043,10 @@
       return false;
     }
 
+    // Ignore casts within macro expansions.
+    if (getExprLoc().isMacroID())
+      return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+
     // If this is a cast to a constructor conversion, check the operand.
     // Otherwise, the result of the cast is unused.
     if (CE->getCastKind() == CK_ConstructorConversion)