[clang] [Clang][Driver] Merge the different strategies of how libc++ is included (PR #83721)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 10:46:04 PST 2024
================
@@ -705,6 +705,47 @@ class ToolChain {
AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
+ struct IncludeStrategy {
+ enum AvailabilityOptions {
+ // Check whether the directory is exists before adding it to the
+ // include path. This is the case if AssumeAvailable isn't set.
+ CheckIfAvailable,
+
+ // Don't check whether the directory exists. Just assume it does and add
+ // the include.
+ AssumeAvailable,
+
+ // Use v<MaxNumber> that is inside `<IncludeRoot>/c++`. If not set, always
+ // uses v1.
+ UseMaxVersionAvailable,
+ };
+
+ IncludeStrategy(AvailabilityOptions Availability,
+ bool AddTargetDirIfAvailable = false,
+ bool PrintDebugStatements = false)
+ : Availability(Availability),
+ AddTargetDirIfAvailable(AddTargetDirIfAvailable),
+ PrintDebugStatements(PrintDebugStatements) {}
+
+ LLVM_PREFERRED_TYPE(AvailabilityOptions)
+ unsigned Availability : 2;
+
+ // Check whether the directory `<IncludeRoot>/<target-triple>/c++/v<N>`
+ // exists, and add it to the include path if it does.
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned AddTargetDirIfAvailable : 1;
+
+ // Whether to print a message if a checked directory isn't available.
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned PrintDebugStatements : 1;
+ };
+
+ /// Helper function to implement AddClangCXXStdlibIncludeArgs for libc++.
+ bool AddLibcxxInclude(const llvm::opt::ArgList &DriverArgs,
----------------
MaskRay wrote:
The case of the first function name character is unfortunately inconsistent, but the convention is that newer function names look like `functionName`, e.g. addLibStdCxxIncludePaths, addGCCLibStdCxxIncludePaths
https://github.com/llvm/llvm-project/pull/83721
More information about the cfe-commits
mailing list