| 1 | //===--- ExpressionTraits.cpp - Expression Traits Support -----------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements the expression traits support functions. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "clang/Basic/ExpressionTraits.h" |
| 14 | #include <cassert> |
| 15 | using namespace clang; |
| 16 | |
| 17 | static constexpr const char *ExpressionTraitNames[] = { |
| 18 | #define EXPRESSION_TRAIT(Spelling, Name, Key) #Name, |
| 19 | #include "clang/Basic/TokenKinds.def" |
| 20 | }; |
| 21 | |
| 22 | static constexpr const char *ExpressionTraitSpellings[] = { |
| 23 | #define EXPRESSION_TRAIT(Spelling, Name, Key) #Spelling, |
| 24 | #include "clang/Basic/TokenKinds.def" |
| 25 | }; |
| 26 | |
| 27 | const char *clang::getTraitName(ExpressionTrait T) { |
| 28 | assert(T <= ET_Last && "invalid enum value!" ); |
| 29 | return ExpressionTraitNames[T]; |
| 30 | } |
| 31 | |
| 32 | const char *clang::getTraitSpelling(ExpressionTrait T) { |
| 33 | assert(T <= ET_Last && "invalid enum value!" ); |
| 34 | return ExpressionTraitSpellings[T]; |
| 35 | } |
| 36 | |