Home | History | Annotate | Download | only in Frontend
      1 //===--- LangStandard.h -----------------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H
     11 #define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
     12 
     13 #include "clang/Basic/LLVM.h"
     14 #include "clang/Frontend/FrontendOptions.h"
     15 #include "llvm/ADT/StringRef.h"
     16 
     17 namespace clang {
     18 
     19 namespace frontend {
     20 
     21 enum LangFeatures {
     22   LineComment = (1 << 0),
     23   C99 = (1 << 1),
     24   C11 = (1 << 2),
     25   CPlusPlus = (1 << 3),
     26   CPlusPlus11 = (1 << 4),
     27   CPlusPlus14 = (1 << 5),
     28   CPlusPlus1z = (1 << 6),
     29   CPlusPlus2a = (1 << 7),
     30   Digraphs = (1 << 8),
     31   GNUMode = (1 << 9),
     32   HexFloat = (1 << 10),
     33   ImplicitInt = (1 << 11),
     34   OpenCL = (1 << 12)
     35 };
     36 
     37 }
     38 
     39 /// LangStandard - Information about the properties of a particular language
     40 /// standard.
     41 struct LangStandard {
     42   enum Kind {
     43 #define LANGSTANDARD(id, name, lang, desc, features) \
     44     lang_##id,
     45 #include "clang/Frontend/LangStandards.def"
     46     lang_unspecified
     47   };
     48 
     49   const char *ShortName;
     50   const char *Description;
     51   unsigned Flags;
     52   InputKind::Language Language;
     53 
     54 public:
     55   /// getName - Get the name of this standard.
     56   const char *getName() const { return ShortName; }
     57 
     58   /// getDescription - Get the description of this standard.
     59   const char *getDescription() const { return Description; }
     60 
     61   /// Get the language that this standard describes.
     62   InputKind::Language getLanguage() const { return Language; }
     63 
     64   /// Language supports '//' comments.
     65   bool hasLineComments() const { return Flags & frontend::LineComment; }
     66 
     67   /// isC99 - Language is a superset of C99.
     68   bool isC99() const { return Flags & frontend::C99; }
     69 
     70   /// isC11 - Language is a superset of C11.
     71   bool isC11() const { return Flags & frontend::C11; }
     72 
     73   /// isCPlusPlus - Language is a C++ variant.
     74   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
     75 
     76   /// isCPlusPlus11 - Language is a C++11 variant (or later).
     77   bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
     78 
     79   /// isCPlusPlus14 - Language is a C++14 variant (or later).
     80   bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; }
     81 
     82   /// isCPlusPlus1z - Language is a C++17 variant (or later).
     83   bool isCPlusPlus1z() const { return Flags & frontend::CPlusPlus1z; }
     84 
     85   /// isCPlusPlus2a - Language is a post-C++17 variant (or later).
     86   bool isCPlusPlus2a() const { return Flags & frontend::CPlusPlus2a; }
     87 
     88 
     89   /// hasDigraphs - Language supports digraphs.
     90   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
     91 
     92   /// isGNUMode - Language includes GNU extensions.
     93   bool isGNUMode() const { return Flags & frontend::GNUMode; }
     94 
     95   /// hasHexFloats - Language supports hexadecimal float constants.
     96   bool hasHexFloats() const { return Flags & frontend::HexFloat; }
     97 
     98   /// hasImplicitInt - Language allows variables to be typed as int implicitly.
     99   bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
    100 
    101   /// isOpenCL - Language is a OpenCL variant.
    102   bool isOpenCL() const { return Flags & frontend::OpenCL; }
    103 
    104   static const LangStandard &getLangStandardForKind(Kind K);
    105   static const LangStandard *getLangStandardForName(StringRef Name);
    106 };
    107 
    108 }  // end namespace clang
    109 
    110 #endif
    111