Guard availability and thread safety attributes against wide strings.
Found by inspection. llvm-svn: 190701
This commit is contained in:
parent
63d233b6ce
commit
ca9fe1453f
|
@ -430,7 +430,7 @@ static void checkAttrArgsAreLockableObjs(Sema &S, Decl *D,
|
|||
|
||||
if (StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
|
||||
if (StrLit->getLength() == 0 ||
|
||||
StrLit->getString() == StringRef("*")) {
|
||||
(StrLit->isAscii() && StrLit->getString() == StringRef("*"))) {
|
||||
// Pass empty strings to the analyzer without warnings.
|
||||
// Treat "*" as the universal lock.
|
||||
Args.push_back(ArgExp);
|
||||
|
@ -2267,10 +2267,16 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
|
|||
AvailabilityChange Obsoleted = Attr.getAvailabilityObsoleted();
|
||||
bool IsUnavailable = Attr.getUnavailableLoc().isValid();
|
||||
StringRef Str;
|
||||
const StringLiteral *SE =
|
||||
dyn_cast_or_null<const StringLiteral>(Attr.getMessageExpr());
|
||||
if (SE)
|
||||
if (Attr.getMessageExpr()) {
|
||||
const StringLiteral *SE = dyn_cast<StringLiteral>(Attr.getMessageExpr());
|
||||
if (!SE || !SE->isAscii()) {
|
||||
S.Diag(Attr.getMessageExpr()->getLocStart(),
|
||||
diag::err_attribute_argument_type)
|
||||
<< Attr.getName() << AANT_ArgumentString;
|
||||
return;
|
||||
}
|
||||
Str = SE->getString();
|
||||
}
|
||||
|
||||
AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), II,
|
||||
Introduced.Version,
|
||||
|
|
|
@ -54,3 +54,5 @@ void f8() {
|
|||
|
||||
extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}}
|
||||
extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}}
|
||||
|
||||
extern int x3 __attribute__((availability(macosx,message=L"wide"))); // expected-error {{'availability' attribute requires a string}}
|
||||
|
|
|
@ -307,6 +307,8 @@ void sl_function_params(int lvar SCOPED_LOCKABLE); // \
|
|||
|
||||
int gb_var_arg GUARDED_BY(mu1);
|
||||
|
||||
int gb_non_ascii GUARDED_BY(L"wide"); // expected-warning {{ignoring 'guarded_by' attribute because its argument is invalid}}
|
||||
|
||||
int gb_var_args __attribute__((guarded_by(mu1, mu2))); // \
|
||||
// expected-error {{'guarded_by' attribute takes one argument}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue