Author: aaronballman
Date: Thu Dec 26 08:54:11 2013
New Revision: 198046
URL: http://llvm.org/viewvc/llvm-project?rev=198046&view=rev
Log:
Removing some unneeded code, and a diagnostic that was obsoleted. The type has
already been determined to be a ValueDecl by virtue of the attribute subjects.
Added some test case coverage as well.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=198046&r1=198045&r2=198046&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Dec 26 08:54:11 2013
@@ -379,28 +379,24 @@ static bool threadSafetyCheckIsSmartPoin
/// \return true if the Decl is a pointer type; false otherwise
static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D,
const AttributeList &Attr) {
- if (const ValueDecl *vd = dyn_cast<ValueDecl>(D)) {
- QualType QT = vd->getType();
- if (QT->isAnyPointerType())
- return true;
-
- if (const RecordType *RT = QT->getAs<RecordType>()) {
- // If it's an incomplete type, it could be a smart pointer; skip it.
- // (We don't want to force template instantiation if we can avoid it,
- // since that would alter the order in which templates are instantiated.)
- if (RT->isIncompleteType())
- return true;
+ const ValueDecl *vd = cast<ValueDecl>(D);
+ QualType QT = vd->getType();
+ if (QT->isAnyPointerType())
+ return true;
- if (threadSafetyCheckIsSmartPointer(S, RT))
- return true;
- }
+ if (const RecordType *RT = QT->getAs<RecordType>()) {
+ // If it's an incomplete type, it could be a smart pointer; skip it.
+ // (We don't want to force template instantiation if we can avoid it,
+ // since that would alter the order in which templates are instantiated.)
+ if (RT->isIncompleteType())
+ return true;
- S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_pointer)
- << Attr.getName()->getName() << QT;
- } else {
- S.Diag(Attr.getLoc(),
diag::err_attribute_can_be_applied_only_to_value_decl)
- << Attr.getName();
+ if (threadSafetyCheckIsSmartPointer(S, RT))
+ return true;
}
+
+ S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_pointer)
+ << Attr.getName()->getName() << QT;
return false;
}
Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=198046&r1=198045&r2=198046&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Thu Dec 26 08:54:11
2013
@@ -4314,3 +4314,15 @@ class A {
} // end namespace NonMemberCalleeICETest
+namespace {
+ int i PT_GUARDED_BY(sls_mu); // expected-warning {{'pt_guarded_by' only
applies to pointer types; type here is 'int'}}
+ int j PT_GUARDED_VAR; // expected-warning {{'pt_guarded_var' only applies
to pointer types; type here is 'int'}}
+
+ void test() {
+ int i PT_GUARDED_BY(sls_mu); // expected-warning {{'pt_guarded_by'
attribute only applies to fields and global variables}}
+ int j PT_GUARDED_VAR; // expected-warning {{'pt_guarded_var' attribute
only applies to fields and global variables}}
+
+ typedef int PT_GUARDED_BY(sls_mu) bad1; // expected-warning
{{'pt_guarded_by' attribute only applies to fields and global variables}}
+ typedef int PT_GUARDED_VAR bad2; // expected-warning {{'pt_guarded_var'
attribute only applies to fields and global variables}}
+ }
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits