Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
llvm-epi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roger Ferrer
llvm-epi
Commits
d543def2
Commit
d543def2
authored
8 years ago
by
Zachary Turner
Browse files
Options
Downloads
Patches
Plain Diff
Allow StringRef to be constructed from a null pointer.
Differential Revision:
https://reviews.llvm.org/D24904
llvm-svn: 282433
parent
f7e07256
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/include/llvm/ADT/StringRef.h
+4
-4
4 additions, 4 deletions
llvm/include/llvm/ADT/StringRef.h
with
4 additions
and
4 deletions
llvm/include/llvm/ADT/StringRef.h
+
4
−
4
View file @
d543def2
...
@@ -73,14 +73,14 @@ namespace llvm {
...
@@ -73,14 +73,14 @@ namespace llvm {
/// Construct an empty string ref.
/// Construct an empty string ref.
/*implicit*/
StringRef
()
:
Data
(
nullptr
),
Length
(
0
)
{}
/*implicit*/
StringRef
()
:
Data
(
nullptr
),
Length
(
0
)
{}
/// Disable conversion from nullptr. This prevents things like
/// if (S == nullptr)
StringRef
(
std
::
nullptr_t
)
=
delete
;
StringRef
(
std
::
nullptr_t
)
=
delete
;
/// Construct a string ref from a cstring.
/// Construct a string ref from a cstring.
LLVM_ATTRIBUTE_ALWAYS_INLINE
/*implicit*/
StringRef
(
const
char
*
Str
)
/*implicit*/
StringRef
(
const
char
*
Str
)
:
Data
(
Str
)
{
:
Data
(
Str
),
Length
(
Str
?
::
strlen
(
Str
)
:
0
)
{}
assert
(
Str
&&
"StringRef cannot be built from a NULL argument"
);
Length
=
::
strlen
(
Str
);
// invoking strlen(NULL) is undefined behavior
}
/// Construct a string ref from a pointer and length.
/// Construct a string ref from a pointer and length.
LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment