Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
llvm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
llvm-watermarker
Commits
b89b43e6
Commit
b89b43e6
authored
Jan 22, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`RangeOptParser` の名前空間を変更
parent
91146f8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
36 deletions
+36
-36
BlockWatermarkPass.cpp
src/nykk/pass/BlockWatermarkPass.cpp
+2
-36
Opts.hpp
src/nykk/pass/Opts.hpp
+34
-0
No files found.
src/nykk/pass/BlockWatermarkPass.cpp
View file @
b89b43e6
...
@@ -9,46 +9,12 @@
...
@@ -9,46 +9,12 @@
namespace
namespace
{
{
template
<
typename
Integer
>
const
llvm
::
cl
::
opt
<
nykk
::
pass
::
RangeOptValue
<
std
::
size_t
>
,
false
,
nykk
::
pass
::
RangeOptParser
<
std
::
size_t
,
2
,
10
>>
partition_opt
struct
RangeOptValue
{
Integer
value
;
};
/**
* @brief Command line option analyzer.
*
* @tparam Integer Integer type.
* @tparam Min Minimum value to accept.
* @tparam Max Maximum value to accept.
*/
template
<
typename
Integer
,
Integer
Min
,
Integer
Max
>
class
RangeOptParser
:
public
llvm
::
cl
::
parser
<
RangeOptValue
<
Integer
>>
{
static_assert
(
std
::
is_integral_v
<
Integer
>
);
public
:
using
llvm
::
cl
::
parser
<
RangeOptValue
<
Integer
>>::
parser
;
// Returns `true` on error.
bool
parse
(
llvm
::
cl
::
Option
&
o
,
llvm
::
StringRef
arg_name
,
llvm
::
StringRef
arg
,
RangeOptValue
<
Integer
>&
value
)
{
if
(
arg
.
getAsInteger
(
0
,
value
.
value
)
||
value
.
value
<
Min
||
Max
<
value
.
value
)
{
return
o
.
error
(
"invalid argument '"
+
arg_name
+
"="
+
arg
+
"'"
);
}
return
false
;
}
};
const
llvm
::
cl
::
opt
<
RangeOptValue
<
std
::
size_t
>
,
false
,
RangeOptParser
<
std
::
size_t
,
2
,
10
>>
partition_opt
{
{
"partition"
,
"partition"
,
llvm
::
cl
::
desc
(
"Block partition number (2 ~ 10 default 7)"
),
llvm
::
cl
::
desc
(
"Block partition number (2 ~ 10 default 7)"
),
llvm
::
cl
::
value_desc
(
"size"
),
llvm
::
cl
::
value_desc
(
"size"
),
llvm
::
cl
::
init
(
RangeOptValue
<
std
::
size_t
>
{
7
}),
llvm
::
cl
::
init
(
nykk
::
pass
::
RangeOptValue
<
std
::
size_t
>
{
7
}),
};
};
/**
/**
...
...
src/nykk/pass/Opts.hpp
View file @
b89b43e6
...
@@ -5,6 +5,40 @@
...
@@ -5,6 +5,40 @@
namespace
nykk
::
pass
namespace
nykk
::
pass
{
{
template
<
typename
Integer
>
struct
RangeOptValue
{
Integer
value
;
};
/**
* @brief Command line option analyzer.
*
* @tparam Integer Integer type.
* @tparam Min Minimum value to accept.
* @tparam Max Maximum value to accept.
*/
template
<
typename
Integer
,
Integer
Min
,
Integer
Max
>
class
RangeOptParser
:
public
llvm
::
cl
::
parser
<
RangeOptValue
<
Integer
>>
{
static_assert
(
std
::
is_integral_v
<
Integer
>
);
public
:
using
llvm
::
cl
::
parser
<
RangeOptValue
<
Integer
>>::
parser
;
// Returns `true` on error.
bool
parse
(
llvm
::
cl
::
Option
&
o
,
llvm
::
StringRef
arg_name
,
llvm
::
StringRef
arg
,
RangeOptValue
<
Integer
>&
value
)
{
if
(
arg
.
getAsInteger
(
0
,
value
.
value
)
||
value
.
value
<
Min
||
Max
<
value
.
value
)
{
return
o
.
error
(
"invalid argument '"
+
arg_name
+
"="
+
arg
+
"'"
);
}
return
false
;
}
};
inline
const
llvm
::
cl
::
opt
<
std
::
string
>
watermark_opt
inline
const
llvm
::
cl
::
opt
<
std
::
string
>
watermark_opt
{
{
"watermark"
,
"watermark"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment