<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 24, 2017, at 10:12 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" class="">aaron@aaronballman.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Wed, May 24, 2017 at 1:05 PM, Argyrios Kyrtzidis <</span><a href="mailto:akyrtzi@gmail.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">akyrtzi@gmail.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class="">On May 24, 2017, at 8:59 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" class="">aaron@aaronballman.com</a>> wrote:<br class=""><br class="">On Tue, May 23, 2017 at 8:46 PM, Argyrios Kyrtzidis via cfe-commits<br class=""><<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:<br class=""><blockquote type="cite" class="">Author: akirtzidis<br class="">Date: Tue May 23 19:46:27 2017<br class="">New Revision: 303712<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=303712&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=303712&view=rev</a><br class="">Log:<br class="">Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well<br class=""><br class="">This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods.<br class=""><br class="">Added:<br class="">  cfe/trunk/test/SemaObjC/diagnose_if.m<br class="">Modified:<br class="">  cfe/trunk/include/clang/Basic/Attr.td<br class="">  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br class="">  cfe/trunk/include/clang/Sema/AttributeList.h<br class="">  cfe/trunk/include/clang/Sema/Sema.h<br class="">  cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br class="">  cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br class="">  cfe/trunk/lib/Sema/SemaExpr.cpp<br class="">  cfe/trunk/lib/Sema/SemaOverload.cpp<br class="">  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp<br class=""><br class="">Modified: cfe/trunk/include/clang/Basic/Attr.td<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Basic/Attr.td (original)<br class="">+++ cfe/trunk/include/clang/Basic/Attr.td Tue May 23 19:46:27 2017<br class="">@@ -149,6 +149,9 @@ class ExprArgument<string name, bit opt<br class="">class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,<br class="">                                                                         opt,<br class="">                                                                         fake>;<br class="">+class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name,<br class="">+                                                                          opt,<br class="">+                                                                          fake>;<br class="">class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;<br class="">class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;<br class="">class VariadicUnsignedArgument<string name> : Argument<name, 1>;<br class="">@@ -1819,14 +1822,14 @@ def Unavailable : InheritableAttr {<br class=""><br class="">def DiagnoseIf : InheritableAttr {<br class=""> let Spellings = [GNU<"diagnose_if">];<br class="">-  let Subjects = SubjectList<[Function]>;<br class="">+  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;<br class=""> let Args = [ExprArgument<"Cond">, StringArgument<"Message">,<br class="">             EnumArgument<"DiagnosticType",<br class="">                          "DiagnosticType",<br class="">                          ["error", "warning"],<br class="">                          ["DT_Error", "DT_Warning"]>,<br class="">             BoolArgument<"ArgDependent", 0, /*fake*/ 1>,<br class="">-              FunctionArgument<"Parent", 0, /*fake*/ 1>];<br class="">+              NamedArgument<"Parent", 0, /*fake*/ 1>];<br class=""> let DuplicatesAllowedWhileMerging = 1;<br class=""> let LateParsed = 1;<br class=""> let AdditionalMembers = [{<br class=""><br class="">Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br class="">+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 19:46:27 2017<br class="">@@ -2771,6 +2771,7 @@ def warn_attribute_wrong_decl_type : War<br class=""> "|types and namespaces"<br class=""> "|Objective-C interfaces"<br class=""> "|methods and properties"<br class="">+  "|functions, methods and properties"<br class=""></blockquote><br class="">functions, methods, and properties (inserting the Oxford comma).<br class=""></blockquote><br class="">Ok.<br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class=""> "|struct or union"<br class=""> "|struct, union or class"<br class=""> "|types"<br class=""><br class="">Modified: cfe/trunk/include/clang/Sema/AttributeList.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Sema/AttributeList.h (original)<br class="">+++ cfe/trunk/include/clang/Sema/AttributeList.h Tue May 23 19:46:27 2017<br class="">@@ -915,6 +915,7 @@ enum AttributeDeclKind {<br class=""> ExpectedTypeOrNamespace,<br class=""> ExpectedObjectiveCInterface,<br class=""> ExpectedMethodOrProperty,<br class="">+  ExpectedFunctionOrMethodOrProperty,<br class=""> ExpectedStructOrUnion,<br class=""> ExpectedStructOrUnionOrClass,<br class=""> ExpectedType,<br class=""><br class="">Modified: cfe/trunk/include/clang/Sema/Sema.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Sema/Sema.h (original)<br class="">+++ cfe/trunk/include/clang/Sema/Sema.h Tue May 23 19:46:27 2017<br class="">@@ -2727,7 +2727,7 @@ public:<br class=""> /// of a function.<br class=""> ///<br class=""> /// Returns true if any errors were emitted.<br class="">-  bool diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,<br class="">+  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,<br class="">                                            SourceLocation Loc);<br class=""><br class=""> /// Returns whether the given function's address can be taken or not,<br class=""><br class="">Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br class="">+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 23 19:46:27 2017<br class="">@@ -1166,6 +1166,7 @@ static bool HasFeature(const Preprocesso<br class="">     .Case("objc_generics", LangOpts.ObjC2)<br class="">     .Case("objc_generics_variance", LangOpts.ObjC2)<br class="">     .Case("objc_class_property", LangOpts.ObjC2)<br class="">+      .Case("objc_diagnose_if_attr", LangOpts.ObjC2)<br class="">     // C11 features<br class="">     .Case("c_alignas", LangOpts.C11)<br class="">     .Case("c_alignof", LangOpts.C11)<br class=""><br class="">Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br class="">+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue May 23 19:46:27 2017<br class="">@@ -949,7 +949,7 @@ static bool checkFunctionConditionAttr(S<br class="">   Msg = "<no message provided>";<br class=""><br class=""> SmallVector<PartialDiagnosticAt, 8> Diags;<br class="">-  if (!Cond->isValueDependent() &&<br class="">+  if (isa<FunctionDecl>(D) && !Cond->isValueDependent() &&<br class="">     !Expr::isPotentialConstantExprUnevaluated(Cond, cast<FunctionDecl>(D),<br class="">                                               Diags)) {<br class="">   S.Diag(Attr.getLoc(), diag::err_attr_cond_never_constant_expr)<br class="">@@ -1037,10 +1037,11 @@ static void handleDiagnoseIfAttr(Sema &S<br class="">   return;<br class=""> }<br class=""><br class="">-  auto *FD = cast<FunctionDecl>(D);<br class="">-  bool ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);<br class="">+  bool ArgDependent = false;<br class="">+  if (auto *FD = dyn_cast<FunctionDecl>(D))<br class=""></blockquote><br class="">Please use const auto *.<br class=""><br class=""><blockquote type="cite" class="">+    ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);<br class=""> D->addAttr(::new (S.Context) DiagnoseIfAttr(<br class="">-      Attr.getRange(), S.Context, Cond, Msg, DiagType, ArgDependent, FD,<br class="">+      Attr.getRange(), S.Context, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D),<br class="">     Attr.getAttributeSpellingListIndex()));<br class="">}<br class=""><br class=""><br class="">Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br class="">+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue May 23 19:46:27 2017<br class="">@@ -366,8 +366,19 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *<br class=""><br class="">   if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))<br class="">     return true;<br class="">+  }<br class=""><br class="">-    if (diagnoseArgIndependentDiagnoseIfAttrs(FD, Loc))<br class="">+  auto getReferencedObjCProp = [](const NamedDecl *D) -><br class="">+                                      const ObjCPropertyDecl * {<br class="">+    if (auto *MD = dyn_cast<ObjCMethodDecl>(D))<br class=""></blockquote><br class="">Please use const auto *.<br class=""></blockquote><br class="">What is the rationale for this, the casted object is ‘const’ already so it’s unnecessary, and I don’t see a mention in coding conventions that we should be using ‘const’ explicitly along with auto.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">That is our usual advice -- why should the reader have to guess</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">whether the pointee type is const or not? It is in the coding</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">standard, but could stand to be called out more explicitly. See the</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">last example in</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>The last example is not clear whether the original pointer was also const so it added ‘const’ redundantly or it added ‘const’ specifically for the duration of the ‘for’ loop.</div><div>Which is why I have a slight preference to omit it, it’s not that I want it to be ‘const’ specifically for the ‘if’ block, I’m passing it along, so if I want it ‘const’ it should be ‘const’ at the ‘source’.</div><div><br class=""></div><div>In any case, I don’t feel strongly about it, I’ll make the changes, but if this is the consensus it should be explicit in the conventions document.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">~Aaron</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">+      return MD->findPropertyDecl();<br class="">+    return nullptr;<br class="">+  };<br class="">+  if (auto *ObjCPDecl = getReferencedObjCProp(D)) {<br class=""></blockquote><br class="">Please do not use auto here (the type is not spelled out in the<br class="">initialization). Also, please mark it explicitly as being a const<br class="">pointer.<br class=""></blockquote><br class="">Ok.<br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">+    if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))<br class="">+      return true;<br class="">+  } else {<br class="">+    if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc))<br class=""></blockquote><br class="">Please bump the if up to be part of the else clause.<br class=""></blockquote><br class="">Ok.<br class=""><br class=""><blockquote type="cite" class=""><br class="">~Aaron<br class=""><br class=""><blockquote type="cite" class="">     return true;<br class=""> }<br class=""><br class=""><br class="">Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br class="">+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue May 23 19:46:27 2017<br class="">@@ -6242,11 +6242,11 @@ EnableIfAttr *Sema::CheckEnableIf(Functi<br class="">}<br class=""><br class="">template <typename CheckFn><br class="">-static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const FunctionDecl *FD,<br class="">+static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND,<br class="">                                       bool ArgDependent, SourceLocation Loc,<br class="">                                       CheckFn &&IsSuccessful) {<br class=""> SmallVector<const DiagnoseIfAttr *, 8> Attrs;<br class="">-  for (const auto *DIA : FD->specific_attrs<DiagnoseIfAttr>()) {<br class="">+  for (const auto *DIA : ND->specific_attrs<DiagnoseIfAttr>()) {<br class="">   if (ArgDependent == DIA->getArgDependent())<br class="">     Attrs.push_back(DIA);<br class=""> }<br class="">@@ -6293,16 +6293,16 @@ bool Sema::diagnoseArgDependentDiagnoseI<br class="">       // EvaluateWithSubstitution only cares about the position of each<br class="">       // argument in the arg list, not the ParmVarDecl* it maps to.<br class="">       if (!DIA->getCond()->EvaluateWithSubstitution(<br class="">-                Result, Context, DIA->getParent(), Args, ThisArg))<br class="">+                Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))<br class="">         return false;<br class="">       return Result.isInt() && Result.getInt().getBoolValue();<br class="">     });<br class="">}<br class=""><br class="">-bool Sema::diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,<br class="">+bool Sema::diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,<br class="">                                                SourceLocation Loc) {<br class=""> return diagnoseDiagnoseIfAttrsWith(<br class="">-      *this, Function, /*ArgDependent=*/false, Loc,<br class="">+      *this, ND, /*ArgDependent=*/false, Loc,<br class="">     [&](const DiagnoseIfAttr *DIA) {<br class="">       bool Result;<br class="">       return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&<br class=""><br class="">Added: cfe/trunk/test/SemaObjC/diagnose_if.m<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/diagnose_if.m?rev=303712&view=auto" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/diagnose_if.m?rev=303712&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/SemaObjC/diagnose_if.m (added)<br class="">+++ cfe/trunk/test/SemaObjC/diagnose_if.m Tue May 23 19:46:27 2017<br class="">@@ -0,0 +1,16 @@<br class="">+// RUN: %clang_cc1 %s -verify -fno-builtin<br class="">+<br class="">+_Static_assert(__has_feature(objc_diagnose_if_attr), "feature check failed?");<br class="">+<br class="">+#define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))<br class="">+<br class="">+@interface I<br class="">+-(void)meth _diagnose_if(1, "don't use this", "warning"); // expected-note 1{{from 'diagnose_if'}}<br class="">+@property (assign) id prop _diagnose_if(1, "don't use this", "warning"); // expected-note 2{{from 'diagnose_if'}}<br class="">+@end<br class="">+<br class="">+void test(I *i) {<br class="">+  [i meth]; // expected-warning {{don't use this}}<br class="">+  id o1 = i.prop; // expected-warning {{don't use this}}<br class="">+  id o2 = [i prop]; // expected-warning {{don't use this}}<br class="">+}<br class=""><br class="">Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=303712&r1=303711&r2=303712&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=303712&r1=303711&r2=303712&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)<br class="">+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue May 23 19:46:27 2017<br class="">@@ -312,7 +312,7 @@ namespace {<br class="">   }<br class=""><br class="">   void writeDump(raw_ostream &OS) const override {<br class="">-      if (type == "FunctionDecl *") {<br class="">+      if (type == "FunctionDecl *" || type == "NamedDecl *") {<br class="">       OS << "    OS << \" \";\n";<br class="">       OS << "    dumpBareDeclRef(SA->get" << getUpperName() << "());\n";<br class="">     } else if (type == "IdentifierInfo *") {<br class="">@@ -1181,6 +1181,8 @@ createArgument(const Record &Arg, String<br class="">   Ptr = llvm::make_unique<ExprArgument>(Arg, Attr);<br class=""> else if (ArgName == "FunctionArgument")<br class="">   Ptr = llvm::make_unique<SimpleArgument>(Arg, Attr, "FunctionDecl *");<br class="">+  else if (ArgName == "NamedArgument")<br class="">+    Ptr = llvm::make_unique<SimpleArgument>(Arg, Attr, "NamedDecl *");<br class=""> else if (ArgName == "IdentifierArgument")<br class="">   Ptr = llvm::make_unique<SimpleArgument>(Arg, Attr, "IdentifierInfo *");<br class=""> else if (ArgName == "DefaultBoolArgument")<br class="">@@ -3103,6 +3105,8 @@ static std::string CalculateDiagnostic(c<br class="">            "            : ExpectedVariableOrFunction))";<br class=""><br class="">   case ObjCMethod | ObjCProp: return "ExpectedMethodOrProperty";<br class="">+    case Func | ObjCMethod | ObjCProp:<br class="">+      return "ExpectedFunctionOrMethodOrProperty";<br class="">   case ObjCProtocol | ObjCInterface:<br class="">     return "ExpectedObjectiveCInterfaceOrProtocol";<br class="">   case Field | Var: return "ExpectedFieldOrGlobalVar";<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</blockquote></blockquote></blockquote></div></blockquote></div><br class=""></body></html>