[PATCH] Some heuristics to identify c style casting (PR18937)
Daniel Jasper
djasper at google.com
Mon May 5 05:57:40 PDT 2014
Two nits, otherwise looks good.
================
Comment at: lib/Format/TokenAnnotator.cpp:794
@@ +793,3 @@
+ } else {
+ // Use heuristics to recognize c style casting
+ FormatToken *Prev = Current.Previous;
----------------
nit: Period at the end of a sentence.
================
Comment at: lib/Format/TokenAnnotator.cpp:807
@@ +806,3 @@
+
+ for (; Prev != Current.MatchingParen; Prev = Prev->Previous)
+ if (!Prev || !Prev->isOneOf(tok::kw_const, tok::identifier)) {
----------------
nit: I'd prefer {} here..
================
Comment at: lib/Format/TokenAnnotator.cpp:806
@@ +805,3 @@
+
+ // only tokens allowed inside () is const and some identifier
+ // isSimpleTypeSpecifier case is already handled above
----------------
Dinesh Dwivedi wrote:
> Daniel Jasper wrote:
> > What about:
> > - * (pointers)
> > - [] (arrays)
> > - <> (templates)
> >
> > ?
> I did not get it. Do you mean something like *(my_int_ptr)+2 etc. I will look for other
> casting example and try to handle them in patch.
>
> If you have anything specific in mind, which should be handled, please suggest.
I mean casts like:
vector<string>* v = (vector<string>*)x;
But nevermind, I think then we don't even get into this branch.
http://reviews.llvm.org/D3576
More information about the cfe-commits
mailing list