source: src/Common/SemanticError.h@ 89be1c68

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 89be1c68 was bf2438c, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Cleaned-up some headers using a tool called 'include-what-you-use'

  • Property mode set to 100644
File size: 1.7 KB
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// SemanticError.h --
8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat Sep 24 15:13:42 2016
13// Update Count : 5
14//
15
16#ifndef SEMANTICERROR_H
17#define SEMANTICERROR_H
18
19#include <exception> // for exception
20#include <iostream> // for ostream
21#include <list> // for list
22#include <string> // for string
23
24#include "utility.h" // for CodeLocation, toString
25
26struct error {
27 std::string description;
28 CodeLocation location;
29
30 error() = default;
31 error( const std::string& str ) : description( str ) {}
32
33 void maybeSet( const CodeLocation& location ) {
34 if( this->location.linenumber < 0 ) {
35 this->location = location;
36 }
37 }
38};
39
40class SemanticError : public std::exception {
41 public:
42 SemanticError();
43 SemanticError( std::string error );
44 template< typename T > SemanticError( const std::string &error, const T *obj );
45 ~SemanticError() throw() {}
46
47 void append( SemanticError &other );
48 void append( const std::string & );
49 bool isEmpty() const;
50 void print( std::ostream &os );
51
52 void set_location( const CodeLocation& location );
53 // constructs an exception using the given message and the printed
54 // representation of the obj (T must have a print method)
55 private:
56 std::list< error > errors;
57};
58
59template< typename T >
60SemanticError::SemanticError( const std::string &error, const T *obj ) {
61 append( toString( error, obj ) );
62}
63
64#endif // SEMANTICERROR_H
65
66// Local Variables: //
67// tab-width: 4 //
68// mode: c++ //
69// compile-command: "make install" //
70// End: //
Note: See TracBrowser for help on using the repository browser.