[cfe-dev] [RFC] Adding API Notes

Gábor Horváth via cfe-dev cfe-dev at lists.llvm.org
Wed May 17 08:29:10 PDT 2017


I wanted to revive the discussion on adding API notes feature to Clang.

*The description of the feature from the original discussion*

"API notes solve a not-uncommon problem: we invent some new Clang attribute
that would be beneficial to add to some declarations in system headers
(e.g., adding a ‘noreturn’ attribute to the C ‘exit’ function), but we
can’t go around and fix all of the system headers everywhere. With API
notes, we can write a separate YAML file that states that we want to add
‘noreturn’ to the ‘exit’ function: when we feed that YAML file into Clang
as part of normal compilation (via a command-line option), Clang will add
‘noreturn’ to the ‘exit’ function when it parses the declaration of ‘exit’."

The old discussion can be found here:

*The summary of the discussion*

* It would be useful for the static analyzer to attach additional info to
the functions
* There were already other trials to get similar feature working, see
* Anna has a nice summary what is the problem with augmented declarations:
* C++ support is requested by the community, this is missing right now.
* Wider range of annotation support is missing. It is also requested by the
* Parameter annotations are supported
* One of the concerns is the performance

*The case for adding API Notes*

* Importing annotations from external source looks to be an interesting
feature for the community
* Sean presented some API checkers which works based on special
* Similar feature can be used to provide fake implementations for
functions. It could help to finish a half done feature of the Static
Analyzer that was implemented during a GSoC project:
* Performance might be crucial for regular compilation, but less of a
problem for the Clang Static Analyzer which tends to be slower than
compilations, so it is less likely to be bottlenecked by this phase
* It would also be possible to import sanitizer/optimizer/codegen related

*Proposed roadmap*

* Commit the feature as is
* Extend it with C++ support (namespaces, overloading, templates..)
* Extend it with additional annotations, and attaching custom data (like
fake function bodies)

What do you think? What are the main concerns with this feature?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170517/0dd9205d/attachment.html>

More information about the cfe-dev mailing list