<div dir="ltr">Hi Shen, documentation for __has_attribute says: <span style="color:rgb(51,51,51);font-family:'DejaVu Sans',Arial,Helvetica,sans-serif;font-size:14px;line-height:21.6000003814697px;text-align:justify">This function-like macro takes a single identifier argument that is the name of an attribute. It evaluates to 1 if the attribute is supported by the current compilation target, or 0 if not. </span><div><br></div><div>So this macro is used to query the compiler support for a specific attribute.</div><div><br></div><div>As far as I understand attributes are mostly useful "inside" the compiler but you'd like to annotate your variable and query this attribute from the code? As in:</div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">int x __attribute_(foo);</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">if (__has_attribute(foo, x)) { ... some code }</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Is that what you're trying to do?</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">Aaron should know this, he's the main attributor :P</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 4, 2014 at 3:12 AM, Shen Liu <span dir="ltr"><<a href="mailto:liushenster@gmail.com" target="_blank">liushenster@gmail.com</a>></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"><div dir="ltr">Dear Clang Developers,<div><br></div><div>I am Shen, a beginner in 
Clang and LLVM. I hope to add some attributes to some variables, and 
check which variables include which attributes in my program. For 
example, I can write a statement as:</div><div><br></div><div>int x __attribute_(foo); (here "foo" is an attribute defined by myself)</div><div><br></div><div>and
 then how can i check whether x has attribute "foo"?  In Clang manual, 
the macro "__has_attribute" is just used for adding attribute for clang,
 not for a concrete variable. Can you give me some help?</div><div><br></div><div><br></div><div>This
 is the first time for me to use this way to ask questions about LLVM, 
if anything wrong please let me know so i can use a better way to get 
your help.</div><div><br></div><div>Thank you very much and have a nice day!<span class=""><font color="#888888"><br><br></font></span></div><span class=""><font color="#888888"><div>Shen<br></div></font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>