[cfe-dev] QualType

Eli Friedman via cfe-dev cfe-dev at lists.llvm.org
Fri Aug 16 11:42:34 PDT 2019


Like I said in my previous email, the type “int” is ASTContext::IntTy

-Eli

From: Monalisa Rout <monalisa33.rout at gmail.com>
Sent: Friday, August 16, 2019 1:57 AM
To: Eli Friedman <efriedma at quicinc.com>; cfe-dev at lists.llvm.org
Subject: [EXT] Re: QualType

Hello Eli,

I am able to crate QualType for all types of pointers by using ASTContext::getPointerType(). But again I am stuggling for const int.
I am trying to use this method ASTContext<http://swtv.kaist.ac.kr/~bookman01/classclang_1_1ASTContext.html#a5930b71a916bc5b4eea3b69160ef6810>::GetBuiltinType<http://swtv.kaist.ac.kr/~bookman01/classclang_1_1ASTContext.html#a17e4f89e87ad7a5a29c5333b478a384e> (unsigned<http://swtv.kaist.ac.kr/~bookman01/classunsigned.html> ID, GetBuiltinTypeError<http://swtv.kaist.ac.kr/~bookman01/classclang_1_1ASTContext.html#aebda31ac75861bbfdb20ad6c54a2dc50> &Error<http://swtv.kaist.ac.kr/~bookman01/namespaceclang.html#a19a831d7318de60497404ddf66dde9d4a902b0d55fddef6f8d651fe1035b7d4bd>), but not sure if this is the method needs to be used and if so what is the ID value for "int".

Once I get QualType, I can call the addConst<https://clang.llvm.org/doxygen/classclang_1_1QualType.html#a43a8b5d4a9d63c319ad978252426379a> () to get const type qualifier.

Regards,
Mona

On Thu, Aug 15, 2019 at 8:58 PM Eli Friedman <efriedma at quicinc.com<mailto:efriedma at quicinc.com>> wrote:
Usually the cfe-dev mailing list is better for questions like this.

The type “int” is ASTContext::IntTy.  You can use QualType::withConst to add a “const” qualifier, and ASTContext::getPointerType to construct a pointer type.  Putting that together, you can construct a “const int*” with something like “Context->getPointerType(Context->IntTy.withConst())”.

If you haven’t looked at the documentation yet, you might want to read https://clang.llvm.org/docs/IntroductionToTheClangAST.html and https://clang.llvm.org/docs/InternalsManual.html .

-Eli

From: cfe-commits <cfe-commits-bounces at lists.llvm.org<mailto:cfe-commits-bounces at lists.llvm.org>> On Behalf Of Monalisa Rout via cfe-commits
Sent: Thursday, August 15, 2019 7:03 AM
To: cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>
Subject: [EXT] QualType

Hello,
I want to create QualType instances for const int, int* const,  and const int* const.
How can I do that??

Regards,
Mona
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190816/16f2b296/attachment.html>


More information about the cfe-dev mailing list