source: src/Parser/parserutility.cc @ d67cdb7

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since d67cdb7 was d67cdb7, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

merge

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[b87a5ed]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//
[9335ecc]7// parserutility.cc --
[b87a5ed]8//
9// Author           : Rodolfo G. Esteves
10// Created On       : Sat May 16 15:30:39 2015
[ac10576]11// Last Modified By : Andrew Beach
12// Last Modified On : Tus Jul 18 10:12:00 2017
13// Update Count     : 8
[4cb935e]14//
[b87a5ed]15
[a67b60e]16#include "parserutility.h"
[d180746]17
18#include <list>                  // for list
19#include <string>                // for string
20
21#include "SynTree/Constant.h"    // for Constant
22#include "SynTree/Expression.h"  // for UntypedExpr, CastExpr, ConstantExpr
23#include "SynTree/Type.h"        // for BasicType, ZeroType, BasicType::Kind...
[51b7345]24
[e82aa9d]25// rewrite
26//    if ( x ) ...
27// as
28//    if ( (int)(x != 0) ) ...
29
[bdd516a]30Expression *notZeroExpr( Expression *orig ) {
[d67cdb7]31        if( !orig ) return nullptr;
[b87a5ed]32        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
33        comparison->get_args().push_back( orig );
[ac10576]34        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( noQualifiers ), "0", (unsigned long long int)0 ) ) );
[b87a5ed]35        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
[51b7345]36}
[b87a5ed]37
38// Local Variables: //
39// tab-width: 4 //
40// mode: c++ //
41// compile-command: "make install" //
42// End: //
Note: See TracBrowser for help on using the repository browser.