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" 16#include "llvm/ADT/StringRef.h" 17#include "llvm/ADT/StringSwitch.h" 18#include "llvm/Support/ErrorHandling.h" 19#include <cassert> 20 21using namespace clang; 22 23OpenMPDirectiveKind 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 31const 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} 44