<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 8/29/2016 11:49 AM, Anna Zaks wrote:<br>
<blockquote
cite="mid:1BE0EF8F-3A60-4DE5-82AB-E1C976E04CCB@apple.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Aug 29, 2016, at 7:59 AM, Gábor Horváth <<a
moz-do-not-send="true" href="mailto:xazax.hun@gmail.com"
class="">xazax.hun@gmail.com</a>> wrote:</div>
</blockquote>
</div>
<div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">* Using pragmas one can introduce
convenience macros, it might also be better to
suppress code regions<br class="">
</div>
* It is better to suppress based on bug type or
something like that rather than using the name of
the checker (which is not intended to leak out)<br
class="">
</div>
* It is good idea to have line offsets to avoid too
much noise when reading code<br class="">
</div>
<div class="">* Anything against pragmas?<br class="">
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
Another reason pragmas are better than comments is because this
is what the compiler uses for suppressions.</div>
</blockquote>
<br>
I'm not opposed to pragmas in concept, but I don't like the typical
way they are used for compiler warning suppression. In particular,
I strongly dislike the following pattern as the "default" pattern
for warning suppression:<br>
<br>
#if __clang_analyzer__<br>
#pragma static analyzer push<br>
#pragma static analyzer disable deadcode<br>
#endif<br>
// bad code here<br>
#if __clang_analyzer__<br>
#pragma static analyzer pop<br>
#endif<br>
<br>
Things I don't like about that pattern:<br>
* verbose<br>
* requires modifying code before and after the offending line of
code<br>
* usually requires compiler specific guards.<br>
* if you forget the trailer, code still works, but you lose
diagnostics<br>
* if you don't know the push / pop pattern, you end up losing
diagnostics<br>
<br>
I'm fine with that pattern existing in addition to a much more terse
and friendly syntax. I can see the push / pop pattern being useful
for blocks of code. Just don't make that the default.<br>
<br>
Here's a pattern that I'd prefer:<br>
// Common header...<br>
#ifdef __clang_analyzer__<br>
#define CLANG_SUPPRESS_WARNING(category, line_offset)
_Pragma(category, line_offset)<br>
#else<br>
#define CLANG_SUPPRESS_WARNING(category, line_offset)<br>
#endif<br>
// Source file...<br>
CLANG_SUPPRESS_WARNING(deadcode, +1)<br>
// bad code here<br>
<br>
<pre class="moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
</pre>
</body>
</html>