зеркало из https://github.com/microsoft/clang-1.git
Refactor diagnostics for MS attributes without -fms-extensions
This shares the warn_attribute_unused diagnostic and reduces the indentation level. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182096 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
e9aae62e8b
Коммит
8fbda8e4a0
|
@ -4576,8 +4576,20 @@ static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D,
|
|||
// Microsoft specific attribute handlers.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Check if MS extensions or some other language extensions are enabled. If
|
||||
// not, issue a diagnostic that the given attribute is unused.
|
||||
static bool checkMicrosoftExt(Sema &S, const AttributeList &Attr,
|
||||
bool OtherExtension = false) {
|
||||
if (S.LangOpts.MicrosoftExt || OtherExtension)
|
||||
return true;
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
return false;
|
||||
}
|
||||
|
||||
static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||
if (S.LangOpts.MicrosoftExt || S.LangOpts.Borland) {
|
||||
if (!checkMicrosoftExt(S, Attr, S.LangOpts.Borland))
|
||||
return;
|
||||
|
||||
// check the attribute arguments.
|
||||
if (!checkAttributeNumArgs(S, Attr, 1))
|
||||
return;
|
||||
|
@ -4627,15 +4639,11 @@ static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
|||
D->addAttr(::new (S.Context)
|
||||
UuidAttr(Attr.getRange(), S.Context, Str->getString(),
|
||||
Attr.getAttributeSpellingListIndex()));
|
||||
} else
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "uuid";
|
||||
}
|
||||
|
||||
static void handleInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||
if (!S.LangOpts.MicrosoftExt) {
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
if (!checkMicrosoftExt(S, Attr))
|
||||
return;
|
||||
}
|
||||
|
||||
AttributeList::Kind Kind = Attr.getKind();
|
||||
if (Kind == AttributeList::AT_SingleInheritance)
|
||||
|
@ -4656,7 +4664,9 @@ static void handleInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
|||
}
|
||||
|
||||
static void handlePortabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||
if (S.LangOpts.MicrosoftExt) {
|
||||
if (!checkMicrosoftExt(S, Attr))
|
||||
return;
|
||||
|
||||
AttributeList::Kind Kind = Attr.getKind();
|
||||
if (Kind == AttributeList::AT_Ptr32)
|
||||
D->addAttr(
|
||||
|
@ -4670,17 +4680,14 @@ static void handlePortabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
|||
D->addAttr(
|
||||
::new (S.Context) Win64Attr(Attr.getRange(), S.Context,
|
||||
Attr.getAttributeSpellingListIndex()));
|
||||
} else
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
}
|
||||
|
||||
static void handleForceInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||
if (S.LangOpts.MicrosoftExt)
|
||||
if (!checkMicrosoftExt(S, Attr))
|
||||
return;
|
||||
D->addAttr(::new (S.Context)
|
||||
ForceInlineAttr(Attr.getRange(), S.Context,
|
||||
Attr.getAttributeSpellingListIndex()));
|
||||
else
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Загрузка…
Ссылка в новой задаче