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", Language::CXX) 29 .Case("cppm", Language::CXX) 30 .Case("iim", InputKind(Language::CXX).getPreprocessed()) 31 .Case("cl", Language::OpenCL) 32 .Case("cu", Language::CUDA) 33 .Cases("ll", "bc", Language::LLVM_IR) 34 .Default(Language::Unknown); 35 } 36