Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 1 | //===--- OpenMPKinds.cpp - Token Kinds Support ----------------------------===// |
| 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 | /// \file |
| 10 | /// \brief This file implements the OpenMP enum and support functions. |
| 11 | /// |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/Basic/OpenMPKinds.h" |
| 15 | #include "clang/Basic/IdentifierTable.h" |
Matt Beaumont-Gay | b63d8d2 | 2013-03-25 21:32:02 +0000 | [diff] [blame^] | 16 | #include "llvm/ADT/StringRef.h" |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/StringSwitch.h" |
| 18 | #include "llvm/Support/ErrorHandling.h" |
| 19 | #include <cassert> |
| 20 | |
| 21 | using namespace clang; |
| 22 | |
| 23 | OpenMPDirectiveKind clang::getOpenMPDirectiveKind(StringRef Str) { |
| 24 | return llvm::StringSwitch<OpenMPDirectiveKind>(Str) |
| 25 | #define OPENMP_DIRECTIVE(Name) \ |
| 26 | .Case(#Name, OMPD_##Name) |
| 27 | #include "clang/Basic/OpenMPKinds.def" |
| 28 | .Default(OMPD_unknown); |
| 29 | } |
| 30 | |
| 31 | const char *clang::getOpenMPDirectiveName(OpenMPDirectiveKind Kind) { |
| 32 | assert(Kind < NUM_OPENMP_DIRECTIVES); |
| 33 | switch (Kind) { |
| 34 | case OMPD_unknown: |
| 35 | return ("unknown"); |
| 36 | #define OPENMP_DIRECTIVE(Name) \ |
| 37 | case OMPD_##Name : return #Name; |
| 38 | #include "clang/Basic/OpenMPKinds.def" |
| 39 | default: |
| 40 | break; |
| 41 | } |
| 42 | llvm_unreachable("Invalid OpenMP directive kind"); |
| 43 | } |