source: src/AST/AssertAcyclic.cpp @ 2d8a770

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 2d8a770 was be8518f, checked in by Andrew Beach <ajbeach@…>, 5 years ago

Fixed up AssertAcyclic?.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2019 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// AssertAcyclic.cpp -- Check that ast::ptr does not form a cycle.
8//
9// Author           : Andrew Beach
10// Created On       : Thu Jun 06 15:00:00 2019
11// Last Modified By : Andrew Beach
12// Last Modified On : Fri Jun 07 14:32:00 2019
13// Update Count     : 1
14//
15
16#include "AssertAcyclic.hpp"
17
18#include "AST/Pass.hpp"
19
20namespace {
21
22class NoStrongCyclesCore {
23    std::vector<const ast::Node *> parents;
24public:
25        void previsit( const ast::Node * node ) {
26                for (auto & parent : parents) {
27                        assert(parent != node);
28                }
29                parents.push_back(node);
30        }
31        void postvisit( const ast::Node * ) {
32                parents.pop_back();
33        }
34};
35
36}
37
38namespace ast {
39
40void assertAcyclic( const std::list< ast::ptr< ast::Decl > > & translationUnit ) {
41        Pass<NoStrongCyclesCore> visitor;
42        for ( auto & decl : translationUnit ) {
43                decl->accept( visitor );
44        }
45}
46
47}
48
49// Local Variables: //
50// tab-width: 4 //
51// mode: c++ //
52// compile-command: "make install" //
53// End: //
Note: See TracBrowser for help on using the repository browser.