This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 00/89] Compile-time gimple-checking

On 04/23/2014 10:42 AM, Michael Matz wrote:

On Mon, 21 Apr 2014, David Malcolm wrote:

     case GIMPLE_SWITCH:
       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);

where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
concrete "gimple_switch" in a release build, with runtime checking for
code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
Unlike others here I do like the cast-as-method (if we absolutely _must_
have a complicated type hierarchy for gimple), but would suggest different
a name: the "gimple_" is tautological, and the "a_" just noise, just name
it "gs->as_switch()" (incidentally then it's _really_ shorter than the
ugly is_a/as_a syntax).

Well, we ought to settle on one... either use the is_a, as_a, and dyn_cast paradigm as they exist today, or we use the cast_as_method approach everywhere. I'm not fond of each potential project having a different approach... I'd like to see a consistent look throughout.

I suspect the cast_as_method has compile time advantages, as well as error reporting ones.... (have you seen the kind of message you get when the template instantiation doesn't work right? ick!) , but it suffers from having to modify the base class whenever a new derived class is added... (which seems a little "dirty" and could impact possible future enhancements).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]