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(S0: "ast" , S1: "pcm" , Value: InputKind(Language::Unknown, InputKind::Precompiled)) |
18 | .Case(S: "c" , Value: Language::C) |
19 | .Cases(S0: "S" , S1: "s" , Value: Language::Asm) |
20 | .Case(S: "i" , Value: InputKind(Language::C).getPreprocessed()) |
21 | .Case(S: "ii" , Value: InputKind(Language::CXX).getPreprocessed()) |
22 | .Case(S: "cui" , Value: InputKind(Language::CUDA).getPreprocessed()) |
23 | .Case(S: "m" , Value: Language::ObjC) |
24 | .Case(S: "mi" , Value: InputKind(Language::ObjC).getPreprocessed()) |
25 | .Cases(S0: "mm" , S1: "M" , Value: Language::ObjCXX) |
26 | .Case(S: "mii" , Value: InputKind(Language::ObjCXX).getPreprocessed()) |
27 | .Cases(S0: "C" , S1: "cc" , S2: "cp" , Value: Language::CXX) |
28 | .Cases(S0: "cpp" , S1: "CPP" , S2: "c++" , S3: "cxx" , S4: "hpp" , S5: "hxx" , Value: Language::CXX) |
29 | .Case(S: "cppm" , Value: Language::CXX) |
30 | .Cases(S0: "iim" , S1: "iih" , Value: InputKind(Language::CXX).getPreprocessed()) |
31 | .Case(S: "cl" , Value: Language::OpenCL) |
32 | .Case(S: "clcpp" , Value: Language::OpenCLCXX) |
33 | .Cases(S0: "cu" , S1: "cuh" , Value: Language::CUDA) |
34 | .Case(S: "hip" , Value: Language::HIP) |
35 | .Cases(S0: "ll" , S1: "bc" , Value: Language::LLVM_IR) |
36 | .Case(S: "hlsl" , Value: Language::HLSL) |
37 | .Case(S: "cir" , Value: Language::CIR) |
38 | .Default(Value: Language::Unknown); |
39 | } |
40 | |