summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2013-07-19 18:53:44 +0000
committerAaron Ballman <aaron@aaronballman.com>2013-07-19 18:53:44 +0000
commitdb6d85ef92726c452e20c3a6cc55e2edd17c686a (patch)
tree20331269ee68ed09b251afc289d0b61c8117d1c4 /clang
parentcda95fe72c4ba4f1682508d4ee5e415cb82e1b66 (diff)
downloadbcm5719-llvm-db6d85ef92726c452e20c3a6cc55e2edd17c686a.tar.gz
bcm5719-llvm-db6d85ef92726c452e20c3a6cc55e2edd17c686a.zip
Replace some existing type attribute diagnostics with a
single diagnostic that selects. No functional changes intended. llvm-svn: 186708
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td13
-rw-r--r--clang/lib/Sema/SemaType.cpp33
2 files changed, 20 insertions, 26 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4bd26d83221..8acdf58dbc9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2015,15 +2015,10 @@ def err_attribute_wrong_decl_type : Error<
"variables, functions and tag types|thread-local variables|"
"variables and fields|variables, data members and tag types|"
"types and namespaces|Objective-C interfaces}1">;
-def warn_function_attribute_wrong_type : Warning<
- "'%0' only applies to function types; type here is %1">,
- InGroup<IgnoredAttributes>;
-def warn_pointer_attribute_wrong_type : Warning<
- "'%0' only applies to pointer types; type here is %1">,
- InGroup<IgnoredAttributes>;
-def warn_objc_object_attribute_wrong_type : Warning<
- "'%0' only applies to Objective-C object or block pointer types; type here is %1">,
- InGroup<IgnoredAttributes>;
+def warn_type_attribute_wrong_type : Warning<
+ "'%0' only applies to %select{function|pointer|"
+ "Objective-C object or block pointer}1 types; type here is %2">,
+ InGroup<IgnoredAttributes>;
def warn_attribute_requires_functions_or_static_globals : Warning<
"%0 only applies to variables with static storage duration and functions">,
InGroup<IgnoredAttributes>;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 80e9b2fba00..42e33faca38 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -38,6 +38,12 @@
using namespace clang;
+enum TypeDiagSelector {
+ TDS_Function,
+ TDS_Pointer,
+ TDS_ObjCObjOrBlock
+};
+
/// isOmittedBlockReturnType - Return true if this declarator is missing a
/// return type because this is a omitted return type on a block literal.
static bool isOmittedBlockReturnType(const Declarator &D) {
@@ -59,23 +65,15 @@ static bool isOmittedBlockReturnType(const Declarator &D) {
/// doesn't apply to the given type.
static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr,
QualType type) {
- bool useExpansionLoc = false;
-
- unsigned diagID = 0;
+ TypeDiagSelector WhichType;
+ bool useExpansionLoc = true;
switch (attr.getKind()) {
- case AttributeList::AT_ObjCGC:
- diagID = diag::warn_pointer_attribute_wrong_type;
- useExpansionLoc = true;
- break;
-
- case AttributeList::AT_ObjCOwnership:
- diagID = diag::warn_objc_object_attribute_wrong_type;
- useExpansionLoc = true;
- break;
-
+ case AttributeList::AT_ObjCGC: WhichType = TDS_Pointer; break;
+ case AttributeList::AT_ObjCOwnership: WhichType = TDS_ObjCObjOrBlock; break;
default:
// Assume everything else was a function attribute.
- diagID = diag::warn_function_attribute_wrong_type;
+ WhichType = TDS_Function;
+ useExpansionLoc = false;
break;
}
@@ -91,7 +89,8 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr,
}
}
- S.Diag(loc, diagID) << name << type;
+ S.Diag(loc, diag::warn_type_attribute_wrong_type) << name << WhichType
+ << type;
}
// objc_gc applies to Objective-C pointers or, otherwise, to the
@@ -4004,8 +4003,8 @@ static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state,
case Qualifiers::OCL_Weak: name = "__weak"; break;
case Qualifiers::OCL_Autoreleasing: name = "__autoreleasing"; break;
}
- S.Diag(AttrLoc, diag::warn_objc_object_attribute_wrong_type)
- << name << type;
+ S.Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
+ << TDS_ObjCObjOrBlock << type;
}
QualType origType = type;
OpenPOWER on IntegriCloud