+TypeDeclaration *get_ultimate_base_type(TypeDeclaration *type)
+{
+ if(!type)
+ return 0;
+ while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
+ {
+ if(!basic->base_type)
+ break;
+ type = basic->base_type;
+ }
+ return type;
+}
+
+bool has_layout_qualifier(const Layout *layout, const string &name)
+{
+ if(!layout)
+ return false;
+ auto i = find_member(layout->qualifiers, name, &Layout::Qualifier::name);
+ return i!=layout->qualifiers.end();
+}
+
+int get_layout_value(const Layout *layout, const string &name, int def_value)
+{
+ if(!layout)
+ return def_value;
+ auto i = find_member(layout->qualifiers, name, &Layout::Qualifier::name);
+ return (i!=layout->qualifiers.end() ? i->value : def_value);
+}
+
+void add_layout_qualifier(RefPtr<Layout> &layout, const Layout::Qualifier &q)