Yep. Replacing "const int" with "int const" really seems like a task for sed.<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 15, 2012 at 4:44 PM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think, that is the exact thing you CANNOT do. AFAIK, asString()<br>
gives you a string representation of the type as the AST sees fit, not<br>
as you have written it in the source.<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Oct 8, 2012 at 8:29 PM, Matthieu Monrocq<br>
<<a href="mailto:matthieu.monrocq@gmail.com">matthieu.monrocq@gmail.com</a>> wrote:<br>
> Actually, I would say there is value in asString. I could write a pass<br>
> to rewrite all "const int" as "int const" using it for example,<br>
> precisely because it matches text.<br>
><br>
> On the other hand, it might be worth using a regex here, or at least<br>
> get rid of whitespace sensitivity (compressing all blanks to a single<br>
> space), if it is really to be used that way.<br>
><br>
> -- Matthieu<br>
><br>
> On Mon, Oct 8, 2012 at 2:52 PM, Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br>
>> I think we should not change the name. We are trying to model the<br>
>> matchers as closely as possible to original AST methods and this case<br>
>> is no exception. We can put a warning into the comment but I don't<br>
>> know, how much good this will do.<br>
>><br>
>> I am not sure what you are referring to with "autotest". I think that<br>
>> test cases are a very good example of where using asString makes<br>
>> sense. It makes them more readable and with the well-controlled<br>
>> environment you are quite sure that asString matches what you think it<br>
>> should match.<br>
>><br>
>><br>
>> On Mon, Oct 8, 2012 at 2:29 PM, Gábor Horváth <<a href="mailto:xazax.hun@gmail.com">xazax.hun@gmail.com</a>> wrote:<br>
>>> It would be great, to mark it as a temporary or internal solution. However<br>
>>> for example there are several autotest using asString, in this case it would<br>
>>> be great, to use it as little as possible.<br>
>>><br>
>>><br>
>>> On 8 October 2012 14:17, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
>>>><br>
>>>> On Mon, Oct 8, 2012 at 2:12 PM, Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br>
>>>> > +cfe-dev<br>
>>>> ><br>
>>>> > The const-case was just an example. You have similar problems with<br>
>>>> > arrays, pointers, references (where to put [], * and &? where to put<br>
>>>> > spaces?), types with typedefs, ...<br>
>>>> ><br>
>>>> > I am working on a sensible way to match types (see<br>
>>>> > <a href="http://llvm-reviews.chandlerc.com/D47" target="_blank">http://llvm-reviews.chandlerc.com/D47</a>), which will enable better Type<br>
>>>> > matching. The AST-matcher language is a good way to describe patterns<br>
>>>> > in the AST and we don't want a second language based on strings. Thus,<br>
>>>> > I am  against extending the functionality of asString in any way.<br>
>>>><br>
>>>> That about sums up what I think, too. Perhaps we should give asString<br>
>>>> a name that makes it clear that we're basically relying on a volatile<br>
>>>> concept? asDebugString? asInternalStringDump?<br>
>>>><br>
>>>> Cheers,<br>
>>>> /Manuel<br>
>>>><br>
>>>> ><br>
>>>> > On Mon, Oct 8, 2012 at 2:06 PM, Gábor Horváth <<a href="mailto:xazax.hun@gmail.com">xazax.hun@gmail.com</a>><br>
>>>> > wrote:<br>
>>>> >> What about forcing asString to only match unqualified types, and force<br>
>>>> >> users<br>
>>>> >> to use isConstqualified and other matchers for qualifiers together with<br>
>>>> >> asString? If asString would match both the cannonical types and<br>
>>>> >> typedefs,<br>
>>>> >> and ignored qualifiers, would it cause any problem? It sounds<br>
>>>> >> considerably<br>
>>>> >> user friendly for me.<br>
>>>> >><br>
>>>> >><br>
>>>> >> On 8 October 2012 10:31, Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br>
>>>> >>><br>
>>>> >>> We actually had a longish discussion whether we wanted to have the<br>
>>>> >>> asString-matcher at all. The problem is that there is no canonical way<br>
>>>> >>> to convert a Type to a string. As an easy example, you could write in<br>
>>>> >>> the code "const int a;" or "int const a;" and asString() would always<br>
>>>> >>> give you "const int" (or the other, but where can you look that up?).<br>
>>>> >>> We decided on including it simply wrapping QualType::asString() just<br>
>>>> >>> because it is very convenient in some places. I don't see an easy way<br>
>>>> >>> of making this a good general purpose user interface.<br>
>>>> >>><br>
>>>> >>> On Sun, Oct 7, 2012 at 10:38 PM, Gábor Horváth <<a href="mailto:xazax.hun@gmail.com">xazax.hun@gmail.com</a>><br>
>>>> >>> wrote:<br>
>>>> >>> > Hi!<br>
>>>> >>> ><br>
>>>> >>> > With "_Bool" it works flawlessly thanks. I wonder if isBoolean is an<br>
>>>> >>> > user<br>
>>>> >>> > friendly solution, as one might except to use asString with any<br>
>>>> >>> > type.<br>
>>>> >>> > However I admint, making asString matcher able to match everything<br>
>>>> >>> > might<br>
>>>> >>> > add<br>
>>>> >>> > unnecessary complexity.<br>
>>>> >>> ><br>
>>>> >>> > Thanks,<br>
>>>> >>> > Gábor<br>
>>>> >>> ><br>
>>>> >>> ><br>
>>>> >>> > On 7 October 2012 22:21, Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br>
>>>> >>> >><br>
>>>> >>> >> +cfe-dev<br>
>>>> >>> >><br>
>>>> >>> >> Hi Gábor,<br>
>>>> >>> >><br>
>>>> >>> >> I think the AST-internal-name of the type bool is '_Bool'. Can you<br>
>>>> >>> >> try<br>
>>>> >>> >> that with the asString-matcher? However, I think the right solution<br>
>>>> >>> >> would be to write a matcher like:<br>
>>>> >>> >><br>
>>>> >>> >> AST_MATCHER(QualType, isBoolean) {<br>
>>>> >>> >>   return Node->isBooleanType();<br>
>>>> >>> >> }<br>
>>>> >>> >><br>
>>>> >>> >> Cheers,<br>
>>>> >>> >> Daniel<br>
>>>> >>> >><br>
>>>> >>> >> On Sun, Oct 7, 2012 at 10:06 PM, Gábor Horváth<br>
>>>> >>> >> <<a href="mailto:xazax.hun@gmail.com">xazax.hun@gmail.com</a>><br>
>>>> >>> >> wrote:<br>
>>>> >>> >> > Hi!<br>
>>>> >>> >> ><br>
>>>> >>> >> > I can't figure out how can I match bool types.<br>
>>>> >>> >> ><br>
>>>> >>> >> > First of all, I had a matcher like this:<br>
>>>> >>> >> ><br>
>>>> >>> >> ><br>
>>>> >>> >> ><br>
>>>> >>> >> > classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(asString("bool"))))<br>
>>>> >>> >> ><br>
>>>> >>> >> > but asString("bool") did not give me any match, however using any<br>
>>>> >>> >> > other<br>
>>>> >>> >> > types would. First of all, I thought, maybe bool is a typedef,<br>
>>>> >>> >> > and<br>
>>>> >>> >> > that<br>
>>>> >>> >> > can<br>
>>>> >>> >> > cause the problem, so I alstered the asString matcher, to also<br>
>>>> >>> >> > check<br>
>>>> >>> >> > the<br>
>>>> >>> >> > name of the cannonical type.<br>
>>>> >>> >> ><br>
>>>> >>> >> > It looks now like this one:<br>
>>>> >>> >> > AST_MATCHER_P(QualType, asString, std::string, Name) {<br>
>>>> >>> >> >   return Name == Node.getAsString() || Name ==<br>
>>>> >>> >> > Node.getCanonicalType().getAsString();<br>
>>>> >>> >> > }<br>
>>>> >>> >> ><br>
>>>> >>> >> > However I still has no success.<br>
>>>> >>> >> ><br>
>>>> >>> >> > Thanks for your answer in advance,<br>
>>>> >>> >> > Gábor<br>
>>>> >>> ><br>
>>>> >>> ><br>
>>>> >><br>
>>>> >><br>
>>>> ><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>
>>><br>
>><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>
_______________________________________________<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>
</div></div></blockquote></div><br></div>