[cfe-dev] Question about Decl::isUsed()

Mikhail Ramalho via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 3 14:12:38 PDT 2018


Thanks for the tip, Paul! I tried the patch and it definitely helped
removing a number of unreferenced typedefs. I didn't help with the TagDecls
though.

Also might point out how these tracking flags might not be perfectly
> handled in things that don't turn into object-file entities, such as
> typedefs.
>

I see, maybe I should create a visitor to replace all typedefs with the
underlying type, then remove all typedefs.

I guess it should work since I'm only using preprocessed files.

Thank you,


> --paulr
>
>
>
> *From:* cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] *On Behalf Of *Mikhail
> Ramalho via cfe-dev
> *Sent:* Tuesday, July 03, 2018 1:14 PM
> *To:* Mikhail Ramalho via cfe-dev
> *Subject:* [cfe-dev] Question about Decl::isUsed()
>
>
>
> Hi everyone,
>
>
>
> I'm trying to write a tool to remove unused declarations from preprocessed
> files but found an odd behaviour when using the Decl::isUsed() call.
>
>
>
> It works great with clang::FunctionDecl and clang::ValueDecl, but when I
> try to check the flag for clang::TagDecl or clang::TypedefNameDecl, it's
> always false, even if it's used in the preprocessed file.
>
>
>
> Is that the expected behaviour? I know that there might be problems when
> dealing with cross TUs but I have a single preprocessed file and everything
> is marked as unused.
>
>
>
> Thank you,
>
>
>
> --
>
>
>
> Mikhail Ramalho.
>


-- 

Mikhail Ramalho.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180703/f5db0c41/attachment.html>


More information about the cfe-dev mailing list