Changeset b3976bf for driver


Ignore:
Timestamp:
Aug 12, 2019, 11:05:36 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
dee1f89
Parents:
cc4218f (diff), 4f5a8a2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
driver
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • driver/Makefile.in

    rcc4218f rb3976bf  
    218218CYGPATH_W = @CYGPATH_W@
    219219DEFS = @DEFS@
     220DEMANGLER = @DEMANGLER@
    220221DEPDIR = @DEPDIR@
    221222DLLTOOL = @DLLTOOL@
     
    243244LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
    244245LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
     246LIBDEMANGLE = @LIBDEMANGLE@
    245247LIBOBJS = @LIBOBJS@
    246248LIBS = @LIBS@
  • driver/cfa.cc

    rcc4218f rb3976bf  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Feb 10 08:28:09 2019
    13 // Update Count     : 281
     12// Last Modified On : Sat Aug 10 08:44:15 2019
     13// Update Count     : 311
    1414//
    1515
     
    2020#include <string>                                                                               // STL version
    2121#include <string.h>                                                                             // strcmp
     22#include <algorithm>                                                                    // find
    2223
    2324#include <sys/types.h>
     
    2627#include "Common/SemanticError.h"
    2728#include "config.h"                                                                             // configure info
     29
    2830
    2931using std::cerr;
     
    4042} // prefix
    4143
    42 enum { NumSuffixes = 2 };
    43 const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    44 
    45 bool suffix( string arg, const char * args[], int & nargs ) {
     44bool suffix( string arg ) {
     45        enum { NumSuffixes = 3 };
     46        static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
    4647        //std::cerr << arg << std::endl;
    4748        size_t dot = arg.find_last_of( "." );
    4849        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    4950        if ( dot == string::npos ) return false;
    50         string sx = arg.substr( dot + 1 );
    51         for ( int i = 0; i < NumSuffixes; i += 1 ) {
    52                 if ( sx == suffixes[i] ) {
    53                         args[nargs] = "-x";
    54                         nargs += 1;
    55                         args[nargs] = "c";
    56                         nargs += 1;
    57                         return true;
    58                 } // if
    59         } // for
    60         return false;
     51        const string * end = suffixes + NumSuffixes;
     52        return std::find( suffixes, end, arg.substr( dot + 1 ) ) != end;
    6153} // suffix
    6254
    6355
    64 void shuffle( const char *args[], int S, int E, int N ) {
     56void shuffle( const char * args[], int S, int E, int N ) {
    6557        // S & E index 1 passed the end so adjust with -1
    6658        #ifdef __DEBUG_H__
     
    7567} // shuffle
    7668
    77 static inline bool dirExists(const string & path) {
     69static inline bool dirExists( const string & path ) {
    7870    struct stat info;
    7971    if(stat( path.c_str(), &info ) != 0)
     
    8880#define str(s) #s
    8981
    90 int main( int argc, char *argv[] ) {
     82int main( int argc, char * argv[] ) {
    9183        string Version( CFA_VERSION_LONG );                                     // current version number from CONFIG
    9284        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
     
    10496        string compiler_name;                                                           // name of C compiler
    10597
     98        bool x_flag = false;                                                            // -x flag
    10699        bool nonoptarg = false;                                                         // indicates non-option argument specified
    107100        bool link = true;                                                                       // linking as well as compiling
    108101        bool verbose = false;                                                           // -v flag
    109         bool quiet = false;                                                             // -quiet flag
    110         bool debug = true;                                                              // -debug flag
    111         bool nolib = false;                                                             // -nolib flag
    112         bool help = false;                                                              // -help flag
     102        bool quiet = false;                                                                     // -quiet flag
     103        bool debug = true;                                                                      // -debug flag
     104        bool nolib = false;                                                                     // -nolib flag
     105        bool help = false;                                                                      // -help flag
    113106        bool CFA_flag = false;                                                          // -CFA flag
    114107        bool cpp_flag = false;                                                          // -E or -M flag, preprocessor only
     
    116109        bool noincstd_flag = false;                                                     // -no-include-stdhdr= flag
    117110        bool debugging __attribute(( unused )) = false;         // -g flag
    118         bool m32 = false;                                    // -m32 flag
    119         bool m64 = false;                                    // -m64 flag
     111        bool m32 = false;                                                                       // -m32 flag
     112        bool m64 = false;                                                                       // -m64 flag
    120113        bool intree = false;
    121114
     
    198191                                args[nargs] = argv[i];                                  // pass the argument along
    199192                                nargs += 1;
     193                        } else if ( prefix( arg, "-x" ) ) {                     // file suffix ?
     194                                string lang;
     195                                args[nargs] = argv[i];                                  // pass the argument along
     196                                nargs += 1;
     197                                if ( arg.length() == 2 ) {                              // separate argument ?
     198                                        i += 1;
     199                                        if ( i == argc ) continue;                      // next argument available ?
     200                                        lang = argv[i];
     201                                        args[nargs] = argv[i];                          // pass the argument along
     202                                        nargs += 1;
     203                                } else {
     204                                        lang = arg.substr( 2 );
     205                                } // if
     206                                x_flag = lang != "none";
    200207                        } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
    201208                                std_flag = true;                                                // -std=XX provided
     
    283290                        } // if
    284291                } else {
    285                         bool cfa = suffix( arg, args, nargs );          // check suffix
     292                        bool cfa = suffix( arg );                                       // check suffix
     293                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
     294                                args[nargs] = "-x";
     295                                nargs += 1;
     296                                args[nargs] = "c";
     297                                nargs += 1;
     298                        } // if
    286299                        args[nargs] = argv[i];                                          // concatenate file
    287300                        nargs += 1;
    288                         if ( cfa ) {
     301                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
    289302                                args[nargs] = "-x";
    290303                                nargs += 1;
     
    295308                } // if
    296309        } // for
    297 
    298     args[nargs] = "-x";                                                                 // turn off language
    299     nargs += 1;
    300     args[nargs] = "none";
    301     nargs += 1;
    302310
    303311        #ifdef __x86_64__
Note: See TracChangeset for help on using the changeset viewer.