[PATCH] D69569: isBuiltinFunc() uses StringRef instead of const char*
Guillaume Chatelet via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 29 09:38:54 PDT 2019
gchatelet created this revision.
gchatelet added a reviewer: vlad.tsyrklevich.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gchatelet edited the summary of this revision.
This prevents a bug when passing `nullptr`, `StringRef` ctor would call `strlen(nullptr)`.
This should fix 98f3151a7dded8838fafcb5f46e6c8358def96b8 <https://reviews.llvm.org/rG98f3151a7dded8838fafcb5f46e6c8358def96b8> breaking sanitizer-x86_64-linux-bootstrap-msan.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69569
Files:
clang/include/clang/Basic/Builtins.h
clang/lib/Basic/Builtins.cpp
clang/lib/Sema/SemaDeclAttr.cpp
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1096,7 +1096,7 @@
if (!S.checkStringLiteralArgumentAttr(AL, I, BuiltinName, &LiteralLoc))
return;
- if (Builtin::Context::isBuiltinFunc(BuiltinName.data()))
+ if (Builtin::Context::isBuiltinFunc(BuiltinName))
AddBuiltinName(BuiltinName);
else
S.Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
Index: clang/lib/Basic/Builtins.cpp
===================================================================
--- clang/lib/Basic/Builtins.cpp
+++ clang/lib/Basic/Builtins.cpp
@@ -47,8 +47,7 @@
AuxTSRecords = AuxTarget->getTargetBuiltins();
}
-bool Builtin::Context::isBuiltinFunc(const char *Name) {
- StringRef FuncName(Name);
+bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) {
for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin; ++i)
if (FuncName.equals(BuiltinInfo[i].Name))
return strchr(BuiltinInfo[i].Attributes, 'f') != nullptr;
Index: clang/include/clang/Basic/Builtins.h
===================================================================
--- clang/include/clang/Basic/Builtins.h
+++ clang/include/clang/Basic/Builtins.h
@@ -224,7 +224,7 @@
/// Returns true if this is a libc/libm function without the '__builtin_'
/// prefix.
- static bool isBuiltinFunc(const char *Name);
+ static bool isBuiltinFunc(llvm::StringRef Name);
/// Returns true if this is a builtin that can be redeclared. Returns true
/// for non-builtins.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69569.226916.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191029/175577e9/attachment-0001.bin>
More information about the cfe-commits
mailing list