<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 29, 2015 at 2:15 AM, Daniel Marjamaki <span dir="ltr"><<a href="mailto:daniel.marjamaki@evidente.se" target="_blank">daniel.marjamaki@evidente.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: danielmarjamaki<br>
Date: Fri May 29 04:15:24 2015<br>
New Revision: 238547<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D238547-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=0lCxg3y4Bd7ksJER9qLPFcbMN7rD-JAk1HSYZBR2mRA&s=3Z6fHbq4rH861707nz_g1w7LiBO9-EgZxxz2JRY3jjY&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=238547&view=rev</a><br>
Log:<br>
Refactor MacroInfo so macro arguments can be iterated with range-based for loops.<br>
<br>
No functional change intended.<br>
<br>
Patch by Sebastian Edman!<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Lex/MacroInfo.h<br>
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
    cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Lex/MacroInfo.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Lex_MacroInfo.h-3Frev-3D238547-26r1-3D238546-26r2-3D238547-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=0lCxg3y4Bd7ksJER9qLPFcbMN7rD-JAk1HSYZBR2mRA&s=NoteoV1Vmhqbghy8hs6S11EUCAedWHN2TwVEwEFHa5I&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=238547&r1=238546&r2=238547&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)<br>
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Fri May 29 04:15:24 2015<br>
@@ -178,10 +178,13 @@ public:<br>
   arg_iterator arg_begin() const { return ArgumentList; }<br>
   arg_iterator arg_end() const { return ArgumentList + NumArguments; }<br>
   unsigned getNumArgs() const { return NumArguments; }<br>
+  ArrayRef<const IdentifierInfo *> args() const {<br>
+    return ArrayRef<const IdentifierInfo *>(ArgumentList, NumArguments);<br></blockquote><div><br>Perhaps we should just roll these two members into one ArrayRef member to begin with?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  }<br>
<br>
   /// \brief Return the argument number of the specified identifier,<br>
   /// or -1 if the identifier is not a formal argument identifier.<br>
-  int getArgumentNum(IdentifierInfo *Arg) const {<br>
+  int getArgumentNum(const IdentifierInfo *Arg) const {<br>
     for (arg_iterator I = arg_begin(), E = arg_end(); I != E; ++I)<br>
       if (*I == Arg)<br>
         return I - arg_begin();<br>
<br>
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Lex_PPMacroExpansion.cpp-3Frev-3D238547-26r1-3D238546-26r2-3D238547-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=0lCxg3y4Bd7ksJER9qLPFcbMN7rD-JAk1HSYZBR2mRA&s=_1qgCVEPd8UtEFsrl05AkXorMyEPEFhu3rEjYz2yRDM&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=238547&r1=238546&r2=238547&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri May 29 04:15:24 2015<br>
@@ -362,12 +362,8 @@ static bool isTrivialSingleTokenExpansio<br>
<br>
   // If this is a function-like macro invocation, it's safe to trivially expand<br>
   // as long as the identifier is not a macro argument.<br>
-  for (MacroInfo::arg_iterator I = MI->arg_begin(), E = MI->arg_end();<br>
-       I != E; ++I)<br>
-    if (*I == II)<br>
-      return false;   // Identifier is a macro argument.<br>
+  return std::find(MI->arg_begin(), MI->arg_end(), II) == MI->arg_end();<br>
<br>
-  return true;<br>
 }<br>
<br>
<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Serialization_ASTWriter.cpp-3Frev-3D238547-26r1-3D238546-26r2-3D238547-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=0lCxg3y4Bd7ksJER9qLPFcbMN7rD-JAk1HSYZBR2mRA&s=O7w2YeAzIRGVDj6MoqRmroNBb2Oi-axri36upVAV1gE&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=238547&r1=238546&r2=238547&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri May 29 04:15:24 2015<br>
@@ -2135,9 +2135,8 @@ void ASTWriter::WritePreprocessor(const<br>
       Record.push_back(MI->isGNUVarargs());<br>
       Record.push_back(MI->hasCommaPasting());<br>
       Record.push_back(MI->getNumArgs());<br>
-      for (MacroInfo::arg_iterator I = MI->arg_begin(), E = MI->arg_end();<br>
-           I != E; ++I)<br>
-        AddIdentifierRef(*I, Record);<br>
+      for (const IdentifierInfo *Arg : MI->args())<br>
+        AddIdentifierRef(Arg, Record);<br>
     }<br>
<br>
     // If we have a detailed preprocessing record, record the macro definition<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></div>