ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
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 | // LabelGenerator.cc -- |
---|
8 | // |
---|
9 | // Author : Peter A. Buhr |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Mon Jan 31 18:51:10 2022 |
---|
13 | // Update Count : 71 |
---|
14 | // |
---|
15 | |
---|
16 | using namespace std; |
---|
17 | |
---|
18 | #include "LabelGeneratorNew.hpp" |
---|
19 | |
---|
20 | #include "AST/Attribute.hpp" |
---|
21 | #include "AST/Label.hpp" |
---|
22 | #include "AST/Stmt.hpp" |
---|
23 | using namespace ast; |
---|
24 | |
---|
25 | namespace ControlStruct { |
---|
26 | |
---|
27 | Label newLabel( const string & suffix, const Stmt * stmt ) { |
---|
28 | static int current = 0; |
---|
29 | |
---|
30 | assert( ( (void)"CFA internal error: parameter statement cannot be null pointer", stmt ) ); |
---|
31 | |
---|
32 | enum { size = 128 }; |
---|
33 | char buf[size]; // space to build label |
---|
34 | int len = snprintf( buf, size, "__L%d__%s", current++, suffix.c_str() ); |
---|
35 | assert( ( (void)"CFA Internal error: buffer overflow creating label", len < size ) ); |
---|
36 | |
---|
37 | // What does this do? |
---|
38 | if ( ! stmt->labels.empty() ) { |
---|
39 | len = snprintf( buf + len, size - len, "_%s__", stmt->labels.front().name.c_str() ); |
---|
40 | assert( ( (void)"CFA Internal error: buffer overflow creating label", len < size - len ) ); |
---|
41 | } // if |
---|
42 | |
---|
43 | Label ret_label( stmt->location, buf ); |
---|
44 | ret_label.attributes.push_back( new Attribute( "unused" ) ); |
---|
45 | return ret_label; |
---|
46 | } |
---|
47 | |
---|
48 | } // namespace ControlStruct |
---|
49 | |
---|
50 | // Local Variables: // |
---|
51 | // mode: c++ // |
---|
52 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.