<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Yes I agree.  I’ll look into doing something more general.<div><br><div style=""><div>On Oct 7, 2013, at 10:22 PM, Bob Wilson <<a href="mailto:bob.wilson@apple.com">bob.wilson@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><br class="Apple-interchange-newline">On Oct 7, 2013, at 5:19 PM, Ted Kremenek <<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Interesting.  Yes that seems like a reasonably generic heuristic.  It does get potentially complicated if a macro uses another macro though… conceptually all from the same “expansion”.</div></blockquote><div><br></div>emmintrin.h is just one case.  Many of the ARM Neon intrinsics have this same issue.  I suppose we could use the same _Pragma approach for those, but a more general solution would be nice.</div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Oct 7, 2013, at 5:11 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Maybe we should teach Clang not to warn on shadowing if the declaration and all its uses come from the same macro expansion?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 4:51 PM, Ted Kremenek<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: kremenek<br>Date: Mon Oct  7 18:51:11 2013<br>New Revision: 192143<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=192143&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=192143&view=rev</a><br>Log:<br>Suppress useless -Wshadow warning when using _mm* macros from emmintrin.h<br><br>Fixes <<a href="rdar://problem/10679282">rdar://problem/10679282</a>>.<br><br>I'm not completely satisfied with this patch.  Sprinkling "diagnostic ignored"<br>_Pragmas throughout this file is gross, but I couldn't suppress<br>it for the entire file.<br><br>Modified:<br>    cfe/trunk/lib/Headers/emmintrin.h<br>    cfe/trunk/test/Sema/warn-shadow.c<br><br>Modified: cfe/trunk/lib/Headers/emmintrin.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=192143&r1=192142&r2=192143&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=192143&r1=192142&r2=192143&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Headers/emmintrin.h (original)<br>+++ cfe/trunk/lib/Headers/emmintrin.h Mon Oct  7 18:51:11 2013<br>@@ -826,7 +826,9 @@ _mm_xor_si128(__m128i __a, __m128i __b)<br> }<br><br> #define _mm_slli_si128(a, count) __extension__ ({ \<br>+  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \<br>   __m128i __a = (a); \<br>+   _Pragma("clang diagnostic pop"); \<br>   (__m128i)__builtin_ia32_pslldqi128(__a, (count)*8); })<br><br> static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))<br>@@ -891,7 +893,9 @@ _mm_sra_epi32(__m128i __a, __m128i __cou<br><br><br> #define _mm_srli_si128(a, count) __extension__ ({ \<br>+  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \<br>   __m128i __a = (a); \<br>+  _Pragma("clang diagnostic pop"); \<br>   (__m128i)__builtin_ia32_psrldqi128(__a, (count)*8); })<br><br> static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))<br>@@ -1280,20 +1284,26 @@ _mm_movemask_epi8(__m128i __a)<br> }<br><br> #define _mm_shuffle_epi32(a, imm) __extension__ ({ \<br>+  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \<br>   __m128i __a = (a); \<br>+  _Pragma("clang diagnostic pop"); \<br>   (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si) _mm_set1_epi32(0), \<br>                                    (imm) & 0x3, ((imm) & 0xc) >> 2, \<br>                                    ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); })<br><br> #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \<br>+  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \<br>   __m128i __a = (a); \<br>+  _Pragma("clang diagnostic pop"); \<br>   (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \<br>                                    (imm) & 0x3, ((imm) & 0xc) >> 2, \<br>                                    ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \<br>                                    4, 5, 6, 7); })<br><br> #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \<br>+  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \<br>   __m128i __a = (a); \<br>+  _Pragma("clang diagnostic pop"); \<br>   (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \<br>                                    0, 1, 2, 3, \<br>                                    4 + (((imm) & 0x03) >> 0), \<br>@@ -1386,8 +1396,10 @@ _mm_movemask_pd(__m128d __a)<br> }<br><br> #define _mm_shuffle_pd(a, b, i) __extension__ ({ \<br>+  _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \<br>   __m128d __a = (a); \<br>   __m128d __b = (b); \<br>+  _Pragma("clang diagnostic pop"); \<br>   __builtin_shufflevector(__a, __b, (i) & 1, (((i) & 2) >> 1) + 2); })<br><br> static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))<br><br>Modified: cfe/trunk/test/Sema/warn-shadow.c<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-shadow.c?rev=192143&r1=192142&r2=192143&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-shadow.c?rev=192143&r1=192142&r2=192143&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Sema/warn-shadow.c (original)<br>+++ cfe/trunk/test/Sema/warn-shadow.c Mon Oct  7 18:51:11 2013<br>@@ -1,5 +1,7 @@<br> // RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s<br><br>+#include <emmintrin.h><br>+<br> int i;          // expected-note 3 {{previous declaration is here}}<br><br> void foo() {<br>@@ -59,3 +61,11 @@ void rdar8883302() {<br> void test8() {<br>   int bob; // expected-warning {{declaration shadows a variable in the global scope}}<br> }<br>+<br>+// Test that using two macros from emmintrin do not cause a<br>+// useless -Wshadow warning.<br>+void rdar10679282() {<br>+  __m128i qf = _mm_setzero_si128();<br>+  qf = _mm_slli_si128(_mm_add_epi64(qf, _mm_srli_si128(qf, 8)), 8); // no-warning<br>+  (void) qf;<br>+}<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br></blockquote></div><br></div></blockquote></div><br></div>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></blockquote></div></blockquote></div><br></div></body></html>