Skip to content

Commit

Permalink
Added support for Section Function Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamnarlawar77 committed Sep 14, 2019
1 parent 27ef2b2 commit 8b3ce50
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Attribute.cpp
Expand Up @@ -80,3 +80,20 @@ AlignedAttribute::make_random()
else
return "";
}

SectionAttribute::SectionAttribute(string name, int prob)
: Attribute(name, prob)
{
}

string
SectionAttribute::make_random()
{
if(rnd_flipcoin(prob)){
ostringstream oss;
oss << rnd_upto(10);
return name + "(\"usersection" + oss.str() + "\")";
}
else
return "";
}
8 changes: 8 additions & 0 deletions src/Attribute.h
Expand Up @@ -49,6 +49,14 @@ class AlignedAttribute : public Attribute
string make_random();
};

//Generates usersections to put functions in different sections
class SectionAttribute : public Attribute
{
public:
SectionAttribute(string, int);
string make_random();
};

//Generates function and types attributes
class AttributeGenerator
{
Expand Down
1 change: 1 addition & 0 deletions src/Function.cpp
Expand Up @@ -136,6 +136,7 @@ Function::InitializeAttributes()
func_attr_generator.attributes.push_back(new MultiChoiceAttribute("visibility", FuncAttrProb, visibility_choices));
func_attr_generator.attributes.push_back(new MultiChoiceAttribute("no_sanitize", FuncAttrProb, sanitize_choices));
func_attr_generator.attributes.push_back(new AlignedAttribute("aligned", FuncAttrProb, 16));
func_attr_generator.attributes.push_back(new SectionAttribute("section", FuncAttrProb));
}
}

Expand Down

0 comments on commit 8b3ce50

Please sign in to comment.