ADT
        ast-experimental
        enum
        pthread-emulation
        qualifiedEnum
      
      
        
          | Last change
 on this file since 8761d40a was             fde0a58, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago | 
        
          | 
change assert to assertf
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.4 KB | 
      
      
| Rev | Line |  | 
|---|
| [dd3263c] | 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 | 
|---|
| [fde0a58] | 12 | // Last Modified On : Wed Feb  2 09:11:17 2022 | 
|---|
|  | 13 | // Update Count     : 72 | 
|---|
| [dd3263c] | 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 |  | 
|---|
| [fde0a58] | 30 | assertf( stmt, "CFA internal error: parameter statement cannot be null pointer" ); | 
|---|
| [dd3263c] | 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() ); | 
|---|
| [fde0a58] | 35 | assertf( len < size, "CFA Internal error: buffer overflow creating label" ); | 
|---|
| [dd3263c] | 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() ); | 
|---|
| [fde0a58] | 40 | assertf( len < size - len, "CFA Internal error: buffer overflow creating label" ); | 
|---|
| [dd3263c] | 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.