[lldb] Fix import-std-module tests after libc++ got a new __memory subdirectory
authorRaphael Isemann <teemperor@gmail.com>
Tue, 15 Dec 2020 15:13:17 +0000 (16:13 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Tue, 15 Dec 2020 15:16:00 +0000 (16:16 +0100)
7ad49aec125b3c1205b164331d0aa954d773f890 added a __memory subdirectory to libc++
but the code we use to find libc++ from the debug info support files wasn't
prepared to encounter unknown subdirectories within libc++. The import-std-module
tests automatically fell back to not importing the std module which caused
them to fail.

This patch removes our hardcoded exception for the 'experimental' subdirectory
and instead just ignores all subdirectories of c++/vX/ when searching the
support files.

lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp

index f1272c6..d2162cf 100644 (file)
@@ -38,9 +38,11 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec &f) {
 
   // Check for /c++/vX/ that is used by libc++.
   static llvm::Regex libcpp_regex(R"regex(/c[+][+]/v[0-9]/)regex");
-  if (libcpp_regex.match(f.GetPath())) {
-    // Strip away libc++'s /experimental directory if there is one.
-    posix_dir.consume_back("/experimental");
+  // If the path is in the libc++ include directory use it as the found libc++
+  // path. Ignore subdirectories such as /c++/v1/experimental as those don't
+  // need to be specified in the header search.
+  if (libcpp_regex.match(f.GetPath()) &&
+      parent_path(posix_dir, Style::posix).endswith("c++")) {
     return m_std_inc.TrySet(posix_dir);
   }