[cfe-dev] bool type is represented as "_Bool" in the AST

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 23 09:31:30 PDT 2019


On Tue, Jul 23, 2019 at 12:24 PM Pradeep Kumar <pradeepisro49 at gmail.com> wrote:
>
> Dear Aaron,
>    How do I set it from command line? I am remeber setting the language standard as -std=c++17 in the clangTool.

You don't change it via the command line. If you set the language mode
to C++ in Clang, it should always print as bool automatically. See
CompilerInvocation::setLangDefaults(), where it sets the values for
the LangOptions object used to make printing policies. If you're not
executing Clang, we need more information about how you are setting up
the tool to be able to help.

~Aaron

>
> Regards,
> Pradeep
>
> On Tue, Jul 23, 2019 at 8:48 PM Aaron Ballman <aaron at aaronballman.com> wrote:
>>
>> On Tue, Jul 23, 2019 at 11:12 AM Pradeep Kumar <pradeepisro49 at gmail.com> wrote:
>> >
>> > Dear Aaron,
>> >     Why is it set to "_Bool" by default?
>>
>> It seems to get its default value from LangOptions::Bool, which I
>> believe is set automatically by the language standard mode.
>>
>> > How do I change it?
>>
>> Usually you do this by making a copy of an existing PrintingPolicy
>> object and modifying it.
>>
>> PrintingPolicy PP(WhateverPrintingPolicyYouWereUsing);
>> PP.Bool = 1;
>>
>> Then pass PP into the call to getAsString().
>>
>> ~Aaron
>>
>> >
>> > Regards,
>> > Pradeep
>> >
>> > On Tue, Jul 23, 2019 at 8:32 PM Aaron Ballman <aaron at aaronballman.com> wrote:
>> >>
>> >> On Tue, Jul 23, 2019 at 10:47 AM Pradeep Kumar via cfe-dev
>> >> <cfe-dev at lists.llvm.org> wrote:
>> >> >
>> >> > Dear Clang-developer community,
>> >> >     I am using libTooling to query information about the source. While querying the string representation of the bool type, I get "_Bool" string. I got the string from QualType::getAsString(). Should I be using another function to query the actual type or is it an expected behavior?
>> >> >
>> >> >     I don't get _Bool when dumping the ast except when I dump the QualType Node.
>> >>
>> >> The PrintingPolicy::Bool member dictates this behavior.
>> >>
>> >> ~Aaron
>> >>
>> >> >
>> >> > clang Version: 9.0
>> >> > LLVM Version: 9.0
>> >> >
>> >> > Regards,
>> >> > Pradeep
>> >> > _______________________________________________
>> >> > cfe-dev mailing list
>> >> > cfe-dev at lists.llvm.org
>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list