Skip to content

Commit

Permalink
Add Flang include directory to MSVC toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
kaadam authored and bryanpkc committed Sep 6, 2023
1 parent 5c04f28 commit 1fb77cd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
36 changes: 36 additions & 0 deletions clang/lib/Driver/ToolChains/MSVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,42 @@ void MSVCToolChain::AddSystemIncludeWithSubfolder(
addSystemInclude(DriverArgs, CC1Args, path);
}

#ifdef ENABLE_CLASSIC_FLANG
/// Convert path list to Fortran frontend argument
static void AddFlangSysIncludeArg(const ArgList &DriverArgs,
ArgStringList &Flang1Args,
ToolChain::path_list IncludePathList) {
std::string ArgValue; // Path argument value

// Make up argument value consisting of paths separated by colons
bool first = true;
for (auto P : IncludePathList) {
if (first) {
first = false;
} else {
ArgValue += ";";
}
ArgValue += P;
}

// Add the argument
Flang1Args.push_back("-stdinc");
Flang1Args.push_back(DriverArgs.MakeArgString(ArgValue));
}

void MSVCToolChain::AddFlangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &Flang1Args) const {
path_list IncludePathList;
const Driver &D = getDriver();
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
SmallString<128> P(D.InstalledDir);
llvm::sys::path::append(P, "../include");
IncludePathList.push_back(P.c_str());
AddFlangSysIncludeArg(DriverArgs, Flang1Args, IncludePathList);
}
#endif

void MSVCToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdinc))
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/MSVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
return VSLayout == llvm::ToolsetLayout::VS2017OrNewer;
}

#ifdef ENABLE_CLASSIC_FLANG
void
AddFlangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &Flang1Args) const override;
#endif

void
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
Expand Down

0 comments on commit 1fb77cd

Please sign in to comment.