forked from OSchip/llvm-project
isBuiltinFunc() uses StringRef instead of const char*
Summary: This prevents a bug when passing nullptr, StringRef ctor would call strlen(nullptr). Reviewers: vlad.tsyrklevich Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69569
This commit is contained in:
parent
d6a7da80aa
commit
1c85a2e8dc
|
@ -224,7 +224,7 @@ public:
|
|||
|
||||
/// 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.
|
||||
|
|
|
@ -47,8 +47,7 @@ void Builtin::Context::InitializeTarget(const TargetInfo &Target,
|
|||
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;
|
||||
|
|
|
@ -1096,7 +1096,7 @@ static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue