source: src/ControlStruct/LabelGeneratorNew.cpp @ cc7bbe6

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since cc7bbe6 was fde0a58, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

change assert to assertf

  • Property mode set to 100644
File size: 1.4 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// 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 : Wed Feb  2 09:11:17 2022
13// Update Count     : 72
14//
15
16using namespace std;
17
18#include "LabelGeneratorNew.hpp"
19
20#include "AST/Attribute.hpp"
21#include "AST/Label.hpp"
22#include "AST/Stmt.hpp"
23using namespace ast;
24
25namespace ControlStruct {
26
27Label newLabel( const string & suffix, const Stmt * stmt ) {
28        static int current = 0;
29
30        assertf( stmt, "CFA internal error: parameter statement cannot be null pointer" );
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        assertf( len < size, "CFA Internal error: buffer overflow creating label" );
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                assertf( len < size - len, "CFA Internal error: buffer overflow creating label" );
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.