source: src/Parser/LinkageSpec.h@ 599fbb6

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors 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 599fbb6 was d55d7a6, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Massive change to errors to enable warnings

  • Property mode set to 100644
File size: 2.5 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// LinkageSpec.h --
8//
9// Author : Rodolfo G. Esteves
10// Created On : Sat May 16 13:24:28 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat Jul 22 09:32:16 2017
13// Update Count : 14
14//
15
16#pragma once
17
18#include <string>
19
20#include "Common/CodeLocation.h"
21
22namespace LinkageSpec {
23 // All linkage specs are some combination of these flags:
24 enum {
25 Mangle = 1 << 0,
26 Generate = 1 << 1,
27 Overrideable = 1 << 2,
28 Builtin = 1 << 3,
29
30 NoOfSpecs = 1 << 4,
31 };
32
33 union Spec {
34 unsigned int val;
35 struct {
36 bool is_mangled : 1;
37 bool is_generatable : 1;
38 bool is_overridable : 1;
39 bool is_builtin : 1;
40 };
41 constexpr Spec( unsigned int val ) : val( val ) {}
42 constexpr Spec( Spec const &other ) : val( other.val ) {}
43 // Operators may go here.
44 // Supports == and !=
45 constexpr operator unsigned int () const { return val; }
46 };
47
48
49 Spec linkageCheck( CodeLocation location, const std::string * );
50 // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
51 Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd );
52 /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
53 * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
54 */
55
56 std::string linkageName( Spec );
57
58 // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
59 inline bool isMangled( Spec spec ) { return spec.is_mangled; }
60 inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
61 inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
62 inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
63
64 // Pre-defined flag combinations:
65 // C built-in defined in prelude
66 constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
67 // ordinary
68 constexpr Spec const Cforall = { Mangle | Generate };
69 // not overloadable, not mangled
70 constexpr Spec const C = { Generate };
71 // built by translator (struct assignment)
72 constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
73 // gcc internal
74 constexpr Spec const Compiler = { Builtin };
75 // mangled builtins
76 constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
77 // non-mangled builtins
78 constexpr Spec const BuiltinC = { Generate | Builtin };
79};
80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.