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