Skip to content

Commit 7574d3a

Browse files
committed
Switch to the C++11 implementation (NFC)
1 parent bd45077 commit 7574d3a

File tree

1 file changed

+15
-46
lines changed

1 file changed

+15
-46
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212

1313
#include "Plugins/TypeSystem/Swift/SwiftASTContext.h"
1414

15-
// C++ Includes
16-
#include <mutex> // std::once
17-
#include <queue>
18-
#include <set>
19-
#include <sstream>
20-
2115
#include "swift/AST/ASTContext.h"
2216
#include "swift/AST/ASTDemangler.h"
2317
#include "swift/AST/ASTMangler.h"
@@ -130,6 +124,12 @@
130124
#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
131125
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
132126

127+
#include <mutex>
128+
#include <queue>
129+
#include <regex>
130+
#include <set>
131+
#include <sstream>
132+
133133
namespace {
134134

135135
/// Used to sort the log output.
@@ -1145,11 +1145,6 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path,
11451145
{
11461146
FileSpec faux_swift_dir_spec(swift_dir);
11471147
if (faux_swift_dir_spec) {
1148-
// We can't use a C++11 stdlib regex feature here because it doesn't
1149-
// work on Ubuntu 14.04 x86_64. Once we don't care about supporting
1150-
// that anymore, let's pull the code below back in since it is a
1151-
// simpler implementation using std::regex.
1152-
#if 0
11531148
// Let's try to regex this.
11541149
// We're looking for /some/path/lldb-{os}-{arch}, and want to
11551150
// build the following:
@@ -1168,43 +1163,17 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path,
11681163
const std::string build_tree_resource_dir =
11691164
std::regex_replace(faux_swift_dir, match_regex,
11701165
replace_format);
1171-
#else
1172-
std::string build_tree_resource_dir;
1173-
const std::string faux_swift_dir = faux_swift_dir_spec.GetCString();
1174-
1175-
// Find something that matches lldb- (particularly,
1176-
// the last one).
1177-
const std::string lldb_dash("lldb-");
1178-
auto lldb_pos = faux_swift_dir.rfind(lldb_dash);
1179-
if ((lldb_pos != std::string::npos) && (lldb_pos > 0) &&
1180-
((faux_swift_dir[lldb_pos - 1] == '\\') ||
1181-
(faux_swift_dir[lldb_pos - 1] == '/'))) {
1182-
// We found something that matches ^.+[/\\]lldb-.+$
1183-
std::ostringstream stream;
1184-
// Take everything before lldb- (the path leading up to
1185-
// the lldb dir).
1186-
stream << faux_swift_dir.substr(0, lldb_pos);
1187-
1188-
// replace lldb- with swift-.
1189-
stream << "swift-";
1190-
1191-
// and now tack on the same components from after
1192-
// the lldb- part.
1193-
stream << faux_swift_dir.substr(lldb_pos + lldb_dash.length());
1194-
const std::string build_tree_resource_dir = stream.str();
1166+
LOG_PRINTF(GetLog(LLDBLog::Types),
1167+
"trying ePathTypeSwiftDir regex-based build dir: %s",
1168+
build_tree_resource_dir.c_str());
1169+
FileSpec swift_resource_dir_spec(build_tree_resource_dir.c_str());
1170+
if (IsDirectory(swift_resource_dir_spec)) {
11951171
LOG_PRINTF(GetLog(LLDBLog::Types),
1196-
"trying ePathTypeSwiftDir regex-based build dir: %s",
1197-
build_tree_resource_dir.c_str());
1198-
FileSpec swift_resource_dir_spec(build_tree_resource_dir.c_str());
1199-
if (IsDirectory(swift_resource_dir_spec)) {
1200-
LOG_PRINTF(GetLog(LLDBLog::Types),
1201-
"found Swift resource dir via "
1202-
"ePathTypeSwiftDir + inferred build-tree dir: %s",
1203-
swift_resource_dir_spec.GetCString());
1204-
return swift_resource_dir_spec.GetCString();
1205-
}
1172+
"found Swift resource dir via "
1173+
"ePathTypeSwiftDir + inferred build-tree dir: %s",
1174+
swift_resource_dir_spec.GetCString());
1175+
return swift_resource_dir_spec.GetCString();
12061176
}
1207-
#endif
12081177
}
12091178
}
12101179

0 commit comments

Comments
 (0)