#include "rust-path.h"
#include "rust-session-manager.h"
#include "rust-attribute-values.h"
+#include "rust-macro-expand.h"
namespace Rust {
* should be stripped. Note that attributes must be expanded before calling.
*/
bool
-fails_cfg (const AST::AttrVec &attrs)
+CfgStrip::fails_cfg (const AST::AttrVec &attrs) const
{
auto &session = Session::get_instance ();
if (attr.get_path () == Values::Attributes::CFG
&& !attr.check_cfg_predicate (session))
return true;
+ else if (!expansion_cfg.should_test
+ && attr.get_path () == Values::Attributes::TEST)
+ return true;
}
return false;
}
* should be stripped. Will expand attributes as well.
*/
bool
-fails_cfg_with_expand (AST::AttrVec &attrs)
+CfgStrip::fails_cfg_with_expand (AST::AttrVec &attrs) const
{
auto &session = Session::get_instance ();
attr.as_string ().c_str ());
}
}
+ else if (!expansion_cfg.should_test
+ && attr.get_path () == Values::Attributes::TEST)
+ return true;
}
return false;
}
#include "rust-item.h"
namespace Rust {
+
+// forward declare
+struct ExpansionCfg;
+
// Visitor used to maybe_strip attributes.
class CfgStrip : public AST::DefaultASTVisitor
{
private:
+ bool fails_cfg (const AST::AttrVec &attrs) const;
+
+ bool fails_cfg_with_expand (AST::AttrVec &attrs) const;
+
public:
using DefaultASTVisitor::visit;
- CfgStrip () {}
+ CfgStrip (const ExpansionCfg &expansion_cfg) : expansion_cfg (expansion_cfg)
+ {}
/* Run the AttrVisitor on an entire crate */
void go (AST::Crate &crate);
{
DefaultASTVisitor::visit (item);
}
+
+private:
+ const ExpansionCfg &expansion_cfg;
};
} // namespace Rust
while (!fixed_point_reached && iterations < cfg.recursion_limit)
{
- CfgStrip ().go (crate);
+ CfgStrip (cfg).go (crate);
// Errors might happen during cfg strip pass
bool visitor_dirty = false;