source: src/AST/AssertAcyclic.cpp@ 7cc0344

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 7cc0344 was 7cc0344, checked in by Andrew Beach <ajbeach@…>, 6 years ago

Added a checker that should help debug cycles in new AST.

  • 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 : Thu Jun 06 15:00:00 2019
13// Update Count : 0
14//
15
16#include "AssertAcyclic.hpp"
17
18#include "AST/Pass.hpp"
19
20namespace {
21
22class NoStrongCyclesCore : public ast::WithGuards {
23 std::vector<const ast::Node *> parents;
24public:
25 void previsit ( const ast::Node * node ) {
26 for (auto & p : parents) {
27 assert(p != node);
28 }
29 parents.push_back(node);
30 GuardAction( [this]() { parents.pop_back(); } );
31 }
32};
33
34}
35
36namespace ast {
37
38void assertAcyclic( const std::list< ast::ptr< ast::Decl > > translationUnit ) {
39 Pass<NoStrongCyclesCore> visitor;
40 for ( auto & decl : translationUnit ) {
41 decl->accept( visitor );
42 }
43}
44
45}
46
47// Local Variables: //
48// tab-width: 4 //
49// mode: c++ //
50// compile-command: "make install" //
51// End: //
Note: See TracBrowser for help on using the repository browser.