source: src/Common/Debug.h@ 599fbb6

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 599fbb6 was 25ba999, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Add Debug namespace and treeDump debug routine

  • Property mode set to 100644
File size: 1.7 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2017 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// Debug.h --
8//
9// Author : Rob Schluntz
10// Created On : Fri Sep 1 11:09:14 2017
11// Last Modified By : Rob Schluntz
12// Last Modified On : Fri Sep 1 11:09:36 2017
13// Update Count : 2
14//
15
16#pragma once
17
18#include <string>
19#include <list>
20#include <iostream>
21
22#include "CodeGen/Generate.h"
23#include "Parser/LinkageSpec.h"
24#include "SynTree/Declaration.h"
25
26#define DEBUG
27
28namespace Debug {
29 /// debug codegen a translation unit
30 static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label ) {
31 #ifdef DEBUG
32 std::list< Declaration * > decls;
33
34 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), []( Declaration * decl ) {
35 return ! LinkageSpec::isBuiltin( decl->get_linkage() );
36 });
37
38 std::cerr << "======" << label << "======" << std::endl;
39 CodeGen::generate( decls, std::cerr, false, true );
40 #endif
41 } // dump
42
43 static inline void treeDump( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label ) {
44 #ifdef DEBUG
45 std::list< Declaration * > decls;
46
47 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), []( Declaration * decl ) {
48 return ! LinkageSpec::isBuiltin( decl->get_linkage() );
49 });
50
51 std::cerr << "======" << label << "======" << std::endl;
52 printAll( decls, std::cerr );
53 #endif
54 } // dump
55}
56
57// Local Variables: //
58// tab-width: 4 //
59// mode: c++ //
60// compile-command: "make install" //
61// End: //
Note: See TracBrowser for help on using the repository browser.