FrontendOptions.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //===- FrontendOptions.cpp ------------------------------------------------===//
  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. #include "clang/Frontend/FrontendOptions.h"
  9. #include "clang/Basic/LangStandard.h"
  10. #include "llvm/ADT/StringSwitch.h"
  11. using namespace clang;
  12. InputKind FrontendOptions::getInputKindForExtension(StringRef Extension) {
  13. return llvm::StringSwitch<InputKind>(Extension)
  14. .Cases("ast", "pcm", InputKind(Language::Unknown, InputKind::Precompiled))
  15. .Case("c", Language::C)
  16. .Cases("S", "s", Language::Asm)
  17. .Case("i", InputKind(Language::C).getPreprocessed())
  18. .Case("ii", InputKind(Language::CXX).getPreprocessed())
  19. .Case("cui", InputKind(Language::CUDA).getPreprocessed())
  20. .Case("m", Language::ObjC)
  21. .Case("mi", InputKind(Language::ObjC).getPreprocessed())
  22. .Cases("mm", "M", Language::ObjCXX)
  23. .Case("mii", InputKind(Language::ObjCXX).getPreprocessed())
  24. .Cases("C", "cc", "cp", Language::CXX)
  25. .Cases("cpp", "CPP", "c++", "cxx", "hpp", "hxx", Language::CXX)
  26. .Case("cppm", Language::CXX)
  27. .Cases("iim", "iih", InputKind(Language::CXX).getPreprocessed())
  28. .Case("cl", Language::OpenCL)
  29. .Case("clcpp", Language::OpenCLCXX)
  30. .Cases("cu", "cuh", Language::CUDA)
  31. .Case("hip", Language::HIP)
  32. .Cases("ll", "bc", Language::LLVM_IR)
  33. .Case("hlsl", Language::HLSL)
  34. .Default(Language::Unknown);
  35. }