7 #include <fmt/ostream.h> 12 set <string> annotations;
14 void get_annotations_for_decl(
const Decl * decl_to_check) {
15 if (!decl_to_check) {
return; }
16 for (
auto attr : decl_to_check->getAttrs()) {
17 AnnotateAttr *annotation = dyn_cast<AnnotateAttr>(attr);
19 auto attribute_attr = dyn_cast<AnnotateAttr>(attr);
20 auto annotation_string = attribute_attr->getAnnotation().str();
22 annotations.emplace(annotation->getAnnotation().str());
31 get_annotations_for_decl(decl_to_check);
36 get_annotations_for_decl(decl_to_check);
42 const vector <string>
get()
const {
43 std::vector <string> results;
45 for (
auto &annotation : annotations) {
46 results.push_back(annotation);
51 std::vector <string>
get_regex(
const string ®ex_string)
const {
52 auto re = regex(regex_string);
53 std::vector <string> results;
55 for (
auto &annotation : annotations) {
57 if (std::regex_match(annotation, matches, re)) {
59 if (matches.size() > 1) {
60 results.emplace_back(matches[1]);
68 return std::find(annotations.begin(), annotations.end(), target) != annotations.end();
72 cerr << fmt::format(
"Merging in {} annotations onto {} existing ones", other.
get().size(), this->
get().size())
74 annotations.insert(other.annotations.begin(), other.annotations.end());
static map< const ClassTemplateDecl *, Annotations > annotations_for_class_templates
const vector< string > get() const
void merge(const Annotations &other)
Annotations(const Decl *decl_to_check)
std::vector< string > get_regex(const string ®ex_string) const
bool has(const std::string &target) const
static map< const CXXRecordDecl *, string > names_for_record_decls
static map< const CXXRecordDecl *, Annotations > annotations_for_record_decls
Annotations(const CXXMethodDecl *decl_to_check)