ExpressionTraits.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include "clang/Basic/ExpressionTraits.h"
  13. #include "llvm/Support/ErrorHandling.h"
  14. #include <cassert>
  15. using namespace clang;
  16. static constexpr const char *ExpressionTraitNames[] = {
  17. #define EXPRESSION_TRAIT(Spelling, Name, Key) #Name,
  18. #include "clang/Basic/TokenKinds.def"
  19. };
  20. static constexpr const char *ExpressionTraitSpellings[] = {
  21. #define EXPRESSION_TRAIT(Spelling, Name, Key) #Spelling,
  22. #include "clang/Basic/TokenKinds.def"
  23. };
  24. const char *clang::getTraitName(ExpressionTrait T) {
  25. assert(T <= ET_Last && "invalid enum value!");
  26. return ExpressionTraitNames[T];
  27. }
  28. const char *clang::getTraitSpelling(ExpressionTrait T) {
  29. assert(T <= ET_Last && "invalid enum value!");
  30. return ExpressionTraitSpellings[T];
  31. }