source: src/Parser/LinkageSpec.cc@ c8dfcd3

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since c8dfcd3 was f2a4f6c, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

fixed memory leak in lexer

  • Property mode set to 100644
File size: 2.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//
[79970ed]7// LinkageSpec.cc --
8//
[b87a5ed]9// Author : Rodolfo G. Esteves
10// Created On : Sat May 16 13:22:09 2015
[3b8e52c]11// Last Modified By : Peter A. Buhr
[ab57786]12// Last Modified On : Sun Aug 21 12:32:53 2016
13// Update Count : 17
[79970ed]14//
[b87a5ed]15
[f2a4f6c]16#include <memory>
[51b73452]17#include <string>
18#include <cassert>
19
20#include "LinkageSpec.h"
[d3b7937]21#include "Common/SemanticError.h"
[51b73452]22
[ab57786]23LinkageSpec::Spec LinkageSpec::fromString( const std::string &spec ) {
[f2a4f6c]24 std::unique_ptr<const std::string> guard(&spec); // allocated by lexer
[ab57786]25 if ( spec == "\"Cforall\"" ) {
[b87a5ed]26 return Cforall;
[ab57786]27 } else if ( spec == "\"C\"" ) {
[b87a5ed]28 return C;
29 } else {
[ab57786]30 throw SemanticError( "Invalid linkage specifier " + spec );
31 } // if
[51b73452]32}
33
[8b7ee09]34std::string LinkageSpec::toString( LinkageSpec::Spec linkage ) {
[79970ed]35 assert( linkage >= 0 && linkage < LinkageSpec::NoOfSpecs );
[8b7ee09]36 static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
[3b8e52c]37 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
38 };
39 return linkageKinds[linkage];
[51b73452]40}
41
[ab57786]42bool LinkageSpec::isDecoratable( Spec spec ) {
[79970ed]43 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]44 static bool decoratable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]45 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]46 true, true, false, true, false,
[3b8e52c]47 };
[ab57786]48 return decoratable[spec];
[51b73452]49}
50
[ab57786]51bool LinkageSpec::isGeneratable( Spec spec ) {
[79970ed]52 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]53 static bool generatable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]54 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]55 true, true, true, true, false,
[3b8e52c]56 };
[ab57786]57 return generatable[spec];
[51b73452]58}
59
[ab57786]60bool LinkageSpec::isOverridable( Spec spec ) {
[79970ed]61 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]62 static bool overridable[LinkageSpec::NoOfSpecs] = {
[3b8e52c]63 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]64 true, false, false, true, false,
[3b8e52c]65 };
[ab57786]66 return overridable[spec];
[4aa0858]67}
68
[ab57786]69bool LinkageSpec::isBuiltin( Spec spec ) {
[79970ed]70 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
[8b7ee09]71 static bool builtin[LinkageSpec::NoOfSpecs] = {
[3b8e52c]72 // Intrinsic, Cforall, C, AutoGen, Compiler
[79970ed]73 true, false, false, false, true,
[3b8e52c]74 };
[ab57786]75 return builtin[spec];
[51b73452]76}
[b87a5ed]77
78// Local Variables: //
79// tab-width: 4 //
80// mode: c++ //
81// compile-command: "make install" //
82// End: //
Note: See TracBrowser for help on using the repository browser.