[PATCH] Added check for kind of UnqualifiedId in Declarator::isStaticMember()

Violeta Vukobrat violeta.vukobrat at rt-rk.com
Thu Mar 19 07:01:35 PDT 2015

Hi rnk, petarj,

Method CXXMethodDecl::isStaticOverloadedOperator expects Operator field from the struct OperatorFunctionId, which is a member of the union in the class UnqualifiedId. If the kind of UnqualifiedId is not checked, there is no guarantee that the value that this method receives will be correct, because it can be the value of another union member and not OperatorFunctionId.



Index: lib/Sema/DeclSpec.cpp
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -345,8 +345,9 @@
 bool Declarator::isStaticMember() {
   assert(getContext() == MemberContext);
   return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
-         CXXMethodDecl::isStaticOverloadedOperator(
-             getName().OperatorFunctionId.Operator);
+         (getName().Kind == UnqualifiedId::IK_OperatorFunctionId &&
+          CXXMethodDecl::isStaticOverloadedOperator(
+              getName().OperatorFunctionId.Operator));
 bool DeclSpec::hasTagDefinition() const {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8437.22253.patch
Type: text/x-patch
Size: 655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150319/b4fdec86/attachment.bin>

More information about the cfe-commits mailing list