mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-03 21:16:05 +00:00

This adds file types and handling for three input types, representing a C++20 header unit source: 1. When provided with a complete pathname for the header. 2. For a header to be looked up (by the frontend) in the user search paths 3. For a header to be looked up in the system search paths. We also add a pre-processed file type (although that is a single type, regardless of the original input type). These types may be specified with -xc++-{user,system,header-unit}-header xxxx. These types allow us to disambiguate header unit jobs from PCH ones, and thus we handle these differently from other header jobs in two ways: 1. The job construction is altered to build a C++20 header unit (rather than a PCH file, as would be the case for other headers). 2. When the type is "user" or "system" we defer checking for the file until the front end is run, since we need to look up the header in the relevant paths which are not known at this point. Differential Revision: https://reviews.llvm.org/D121588
38 lines
1.6 KiB
C++
38 lines
1.6 KiB
C++
//===- FrontendOptions.cpp ------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Frontend/FrontendOptions.h"
|
|
#include "clang/Basic/LangStandard.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
using namespace clang;
|
|
|
|
InputKind FrontendOptions::getInputKindForExtension(StringRef Extension) {
|
|
return llvm::StringSwitch<InputKind>(Extension)
|
|
.Cases("ast", "pcm", InputKind(Language::Unknown, InputKind::Precompiled))
|
|
.Case("c", Language::C)
|
|
.Cases("S", "s", Language::Asm)
|
|
.Case("i", InputKind(Language::C).getPreprocessed())
|
|
.Case("ii", InputKind(Language::CXX).getPreprocessed())
|
|
.Case("cui", InputKind(Language::CUDA).getPreprocessed())
|
|
.Case("m", Language::ObjC)
|
|
.Case("mi", InputKind(Language::ObjC).getPreprocessed())
|
|
.Cases("mm", "M", Language::ObjCXX)
|
|
.Case("mii", InputKind(Language::ObjCXX).getPreprocessed())
|
|
.Cases("C", "cc", "cp", Language::CXX)
|
|
.Cases("cpp", "CPP", "c++", "cxx", "hpp", "hxx", Language::CXX)
|
|
.Case("cppm", Language::CXX)
|
|
.Cases("iim", "iih", InputKind(Language::CXX).getPreprocessed())
|
|
.Case("cl", Language::OpenCL)
|
|
.Case("clcpp", Language::OpenCLCXX)
|
|
.Cases("cu", "cuh", Language::CUDA)
|
|
.Case("hip", Language::HIP)
|
|
.Cases("ll", "bc", Language::LLVM_IR)
|
|
.Default(Language::Unknown);
|
|
}
|