source: src/AST/Inspect.cpp @ 91715ce1

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since 91715ce1 was b70abaf, checked in by Thierry Delisle <tdelisle@…>, 23 months ago

Added inspect file for asking questions about the ast.
So far only contains function to check if struct has flexible array.

  • Property mode set to 100644
File size: 916 bytes
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// Node.hpp --
8//
9// Author           : Thierry Delisle
10// Created On       : Fri Jun 24 13:16:31 2022
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16#include "AST/Decl.hpp"
17#include "AST/Type.hpp"
18
19#include <iostream>
20#include <AST/Print.hpp>
21
22namespace ast {
23        bool structHasFlexibleArray( const ast::StructDecl * decl ) {
24                if(decl->members.size() == 0) return false;
25                const auto & last = *decl->members.rbegin();
26                auto lastd = last.as<ast::DeclWithType>();
27                if(!lastd) return false; // I don't know what this is possible, but it might be.
28                auto atype = dynamic_cast<const ast::ArrayType *>(lastd->get_type());
29                if(!atype) return false;
30                return !atype->isVarLen && !atype->dimension;
31        }
32};
Note: See TracBrowser for help on using the repository browser.