25
25
#include " clang/Basic/DiagnosticOptions.h"
26
26
#include " clang/Driver/CommonArgs.h"
27
27
#include " clang/Driver/Driver.h"
28
- #include " clang/Driver/ToolChain.h"
29
28
#include " clang/Driver/OptionUtils.h"
30
29
#include " clang/Driver/Options.h"
31
30
#include " llvm/ADT/ArrayRef.h"
32
31
#include " llvm/ADT/StringRef.h"
33
32
#include " llvm/ADT/StringSwitch.h"
34
- #include " llvm/Support/VirtualFileSystem.h"
35
33
#include " llvm/Frontend/Debug/Options.h"
36
34
#include " llvm/Frontend/Driver/CodeGenOptions.h"
37
35
#include " llvm/Option/Arg.h"
@@ -1501,11 +1499,11 @@ bool CompilerInvocation::createFromArgs(
1501
1499
success = false ;
1502
1500
}
1503
1501
1504
- // User-specified or default resource dir
1502
+ // User-specified or default resource dir
1505
1503
if (const llvm::opt::Arg *a = args.getLastArg (clang::driver::options::OPT_resource_dir))
1506
1504
invoc.resourceDir = a->getValue ();
1507
1505
else
1508
- clang::driver::Driver::GetResourcesPath (llvm::sys::fs::getMainExecutable (argv0, nullptr ));
1506
+ invoc. resourceDir = clang::driver::Driver::GetResourcesPath (llvm::sys::fs::getMainExecutable (argv0, nullptr ));
1509
1507
1510
1508
// -flang-experimental-hlfir
1511
1509
if (args.hasArg (clang::driver::options::OPT_flang_experimental_hlfir) ||
@@ -1726,7 +1724,7 @@ void CompilerInvocation::setDefaultPredefinitions() {
1726
1724
}
1727
1725
}
1728
1726
1729
- void CompilerInvocation::setFortranOpts (const llvm::TargetMachine &targetMachine ) {
1727
+ void CompilerInvocation::setFortranOpts () {
1730
1728
auto &fortranOptions = getFortranOpts ();
1731
1729
const auto &frontendOptions = getFrontendOpts ();
1732
1730
const auto &preprocessorOptions = getPreprocessorOpts ();
@@ -1751,61 +1749,23 @@ void CompilerInvocation::setFortranOpts(const llvm::TargetMachine &targetMachine
1751
1749
preprocessorOptions.searchDirectoriesFromDashI .begin (),
1752
1750
preprocessorOptions.searchDirectoriesFromDashI .end ());
1753
1751
1754
- // Add the ordered list of -fintrinsic-modules-path
1755
- #if 1
1756
- // Legacy
1757
- // TODO: should not be used for finding 'INCLUDE' files
1752
+ // Add the ordered list of -intrinsic-modules-path
1758
1753
fortranOptions.searchDirectories .insert (
1759
1754
fortranOptions.searchDirectories .end (),
1760
- preprocessorOptions.searchDirectoriesFromIntrModPath .begin (), // should this be searchDirectoriesFromDashJ???
1755
+ preprocessorOptions.searchDirectoriesFromIntrModPath .begin (),
1761
1756
preprocessorOptions.searchDirectoriesFromIntrModPath .end ());
1762
- #endif
1763
-
1764
-
1765
-
1766
-
1767
1757
1768
1758
1769
- // Add the default intrinsic module directory
1770
- #if 1
1771
- // gfortran prepends this path to the usual intrinsics dir
1759
+ // Add the ordered list of -fintrinsic-modules-path
1772
1760
fortranOptions.intrinsicModuleDirectories .insert (
1773
1761
fortranOptions.intrinsicModuleDirectories .end (),
1774
1762
preprocessorOptions.searchDirectoriesFromIntrModPath .begin (),
1775
1763
preprocessorOptions.searchDirectoriesFromIntrModPath .end ());
1776
- #endif
1777
-
1778
- // FIXME: Assembling the list of module search paths is the driver's job.
1779
-
1780
- #if 0
1781
- auto vfs = llvm::vfs::createPhysicalFileSystem();
1782
- auto defaultIntrinsicsDir = clang::driver:: ToolChain:: getDefaultIntrinsicModuleDir(getResourceDir(), targetMachine.getTargetTriple(),*vfs , nullptr) ;
1783
- if (defaultIntrinsicsDir)
1784
- fortranOptions.intrinsicModuleDirectories.push_back(*defaultIntrinsicsDir);
1785
- #endif
1786
-
1787
- #if 0
1788
- llvm::errs() << "\nnew intr search dirs:\n";
1789
- for (auto&& x : fortranOptions.intrinsicModuleDirectories) {
1790
- llvm::errs() << x << "\n";
1791
- }
1792
- #endif
1793
-
1794
- #if 0
1795
- llvm::SmallString<128> intrinsicsDir { resourceDir };
1796
- llvm::sys::path::append(intrinsicsDir, "finclude", triple);
1797
- fortranOptions.intrinsicModuleDirectories.emplace_back(intrinsicsDir);
1798
- fortranOptions.intrinsicModuleDirectories.emplace_back(getIntrinsicDir(getArgv0()));
1799
- #endif
1800
1764
1801
-
1802
- // FIXME: Assembling the list of module search paths is the driver's job.
1803
- #if 1
1804
1765
// Add the directory supplied through -J/-module-dir to the list of search
1805
1766
// directories
1806
1767
if (moduleDirJ != " ." )
1807
1768
fortranOptions.searchDirectories .emplace_back (moduleDirJ);
1808
- #endif
1809
1769
1810
1770
if (frontendOptions.instrumentedParse )
1811
1771
fortranOptions.instrumentedParse = true ;
@@ -1825,47 +1785,10 @@ CompilerInvocation::getSemanticsCtx(
1825
1785
const llvm::TargetMachine &targetMachine) {
1826
1786
auto &fortranOptions = getFortranOpts ();
1827
1787
1828
-
1829
-
1830
- #if 0
1831
- auto &moduleDirJ = getModuleDir();
1832
-
1833
- auto triple = targetMachine.getTargetTriple();
1834
- llvm::SmallVector<std::string> searchDirectories{ llvm ::ArrayRef ( fortranOptions.searchDirectories))};
1835
- if (moduleDirJ != ".")
1836
- searchDirectories.emplace_back(moduleDirJ);
1837
-
1838
- llvm::SmallVector<std::string> intrinsicModuleDirectories { llvm::ArrayRef(fortranOptions.intrinsicModuleDirectories)};
1839
-
1840
- // FIXME: Do not modify intrinsicIncludeDirs directly, should be treated as immutable just like argv.
1841
- // TODO: Normlize triple directory as clang does; best refactor with ToolChain::getDefaultIntrinsicModulePaths() used by the flang driver.
1842
- std::string mainExe = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
1843
- llvm::StringRef prefixDir = llvm::sys::path::parent_path( llvm::sys::path::parent_path(mainExe ));
1844
- llvm::SmallString<128> resourceDir (prefixDir);
1845
- llvm::sys::path::append(resourceDir, /*CLANG_INSTALL_LIBDIR_BASENAME*/ "lib", "clang", FLANG_VERSION_MAJOR_STRING);
1846
- llvm::sys::path::append(resourceDir, "finclude", triple);
1847
- llvm::errs() << resourceDir << "\n";
1848
- intrinsicIncludeDirs.push_back(resourceDir.str().str());
1849
-
1850
- #endif
1851
-
1852
-
1853
1788
auto semanticsContext = std::make_unique<semantics::SemanticsContext>(
1854
1789
getDefaultKinds (), fortranOptions.features , getLangOpts (),
1855
1790
allCookedSources);
1856
1791
1857
- #if 0
1858
- llvm::errs() << "\nsearch dirs:\n";
1859
- for (auto&& x : fortranOptions.searchDirectories) {
1860
- llvm::errs() << x << "\n";
1861
- }
1862
-
1863
- llvm::errs() << "\nintrinsic search dirs:\n";
1864
- for (auto&& x : fortranOptions.intrinsicModuleDirectories) {
1865
- llvm::errs() << x << "\n";
1866
- }
1867
- #endif
1868
-
1869
1792
semanticsContext->set_moduleDirectory (getModuleDir ())
1870
1793
.set_searchDirectories (fortranOptions.searchDirectories )
1871
1794
.set_intrinsicModuleDirectories (fortranOptions.intrinsicModuleDirectories )
0 commit comments