Sema: Don't crash on visibility attributes with an identifier argument.
PR17105.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190312 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 78b963c..0a6cee9 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2438,9 +2438,10 @@
if (!checkAttributeNumArgs(S, Attr, 1))
return;
- Expr *Arg = Attr.getArgAsExpr(0);
- Arg = Arg->IgnoreParenCasts();
- StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
+ // Check that the argument is a string literal.
+ StringLiteral *Str = 0;
+ if (Attr.isArgExpr(0))
+ Str = dyn_cast<StringLiteral>(Attr.getArgAsExpr(0)->IgnoreParenCasts());
if (!Str || !Str->isAscii()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)