File tree Expand file tree Collapse file tree 5 files changed +21
-12
lines changed Expand file tree Collapse file tree 5 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,13 @@ def codeql_workspace(repository_name = "codeql"):
43
43
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz" ,
44
44
],
45
45
)
46
+
47
+ maybe (
48
+ repo_rule = http_archive ,
49
+ name = "absl" ,
50
+ sha256 = "cec2e5bf780532bd0ac672eb8d43c0f8bbe84ca5df8718320184034b7f59a398" ,
51
+ urls = [
52
+ "https://github.com/abseil/abseil-cpp/archive/d2c5297a3c3948de765100cb7e5cccca1210d23c.tar.gz" ,
53
+ ],
54
+ strip_prefix = "abseil-cpp-d2c5297a3c3948de765100cb7e5cccca1210d23c" ,
55
+ )
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ swift_cc_binary(
16
16
"//swift/extractor/remapping" ,
17
17
"//swift/extractor/translators" ,
18
18
"//swift/third_party/swift-llvm-support" ,
19
+ "@absl//absl/strings" ,
19
20
],
20
21
)
21
22
Original file line number Diff line number Diff line change 9
9
#include < swift/FrontendTool/FrontendTool.h>
10
10
#include < swift/Basic/InitializeSwiftModules.h>
11
11
12
+ #include " absl/strings/str_join.h"
13
+
12
14
#include " swift/extractor/SwiftExtractor.h"
13
15
#include " swift/extractor/infra/TargetDomains.h"
14
16
#include " swift/extractor/remapping/SwiftFileInterception.h"
@@ -184,18 +186,13 @@ codeql::SwiftExtractorConfiguration configure(int argc, char** argv) {
184
186
return configuration;
185
187
}
186
188
187
- // TODO: use `absl::StrJoin` or `boost::algorithm::join`
188
189
static auto argDump (int argc, char ** argv) {
189
- std::string ret;
190
- for (auto arg = argv + 1 ; arg < argv + argc; ++arg) {
191
- ret += *arg;
192
- ret += ' ' ;
190
+ if (argc < 2 ) {
191
+ return " " s;
193
192
}
194
- ret.pop_back ();
195
- return ret;
193
+ return absl::StrJoin (argv + 1 , argv + argc, " " );
196
194
}
197
195
198
- // TODO: use `absl::StrJoin` or `boost::algorithm::join`
199
196
static auto envDump (char ** envp) {
200
197
std::string ret;
201
198
for (auto env = envp; *env; ++env) {
Original file line number Diff line number Diff line change @@ -50,5 +50,6 @@ swift_cc_library(
50
50
deps = [
51
51
"//swift/extractor/infra/file" ,
52
52
"//swift/extractor/infra/log" ,
53
+ "@absl//absl/numeric:bits" ,
53
54
],
54
55
)
Original file line number Diff line number Diff line change 5
5
#include < iostream>
6
6
#include < string>
7
7
#include < vector>
8
+ #include " absl/numeric/bits.h"
8
9
#include < binlog/binlog.hpp>
9
10
#include < cmath>
10
11
#include < charconv>
@@ -53,10 +54,9 @@ class UntypedTrapLabel {
53
54
54
55
private:
55
56
size_t strSize () const {
56
- if (id_ == undefined) return 17 ; // #ffffffffffffffff
57
- if (id_ == 0 ) return 2 ; // #0
58
- // TODO: use absl::bit_width or C+20 std::bit_width instead of this ugly formula
59
- return /* # */ 1 + /* hex digits */ static_cast <size_t >(ceil (log2 (id_ + 1 ) / 4 ));
57
+ if (id_ == 0 ) return 2 ; // #0
58
+ // Number of hex digits is ceil(bit_width(id) / 4), but C++ integer division can only do floor.
59
+ return /* # */ 1 + /* hex digits */ 1 + (absl::bit_width (id_) - 1 ) / 4 ;
60
60
}
61
61
};
62
62
You can’t perform that action at this time.
0 commit comments