[libc-commits] [libc] [libc] add support for function level attributes (PR #79891)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed Jan 31 12:20:23 PST 2024
================
@@ -47,9 +51,133 @@ static std::string getTypeHdrName(const std::string &Name) {
namespace llvm_libc {
-void writeAPIFromIndex(APIIndexer &G,
- std::vector<std::string> EntrypointNameList,
- llvm::raw_ostream &OS) {
+static AttributeStyle getAttributeStyle(llvm::Record *Instance) {
+ llvm::StringRef Style = Instance->getValueAsString("Style");
+ return llvm::StringSwitch<AttributeStyle>(Style)
+ .Case("cxx11", AttributeStyle::Cxx11)
+ .Case("gnu", AttributeStyle::Gnu)
+ .Case("declspec", AttributeStyle::Declspec)
+ .Default(AttributeStyle::Gnu);
+}
+
+static AttributeNamespace getAttributeNamespace(llvm::Record *Instance) {
+ llvm::StringRef Namespace = Instance->getValueAsString("Namespace");
+ return llvm::StringSwitch<AttributeNamespace>(Namespace)
+ .Case("clang", AttributeNamespace::Clang)
+ .Case("gnu", AttributeNamespace::Gnu)
+ .Default(AttributeNamespace::None);
+}
+
+using AttributeMap = llvm::DenseMap<llvm::StringRef, llvm::Record *>;
+
+template <class SpecMap, class FuncList>
+static AttributeMap collectAttributeMacros(const SpecMap &Spec,
+ const FuncList &Funcs) {
+ llvm::DenseMap<llvm::StringRef, llvm::Record *> MacroAttr;
+ for (const auto &Name : Funcs) {
+ if (!Spec.count(Name))
----------------
SchrodingerZhu wrote:
I generally do not think `Spec.count` followed with a `Spec.at` is a good thing. However, this pattern is repeatedly used in some other places and it is not performance critical anyway.
Tell me if you want me to change this.
https://github.com/llvm/llvm-project/pull/79891
More information about the libc-commits
mailing list