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