<html><body><div>On 15 Sep, 2011,at 05:23 PM, Douglas Gregor <dgregor@apple.com> wrote:<br><br></div><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch"><br>
On Sep 14, 2011, at 9:31 AM, Erik Verbruggen wrote:<br>
<br>
> Hello,<br>
> <br>
> Attached is a patch to add CXAvailability_NotAccessible to indicate that a declaration is available, but not accessible from the current code completion context. Included is a test-case which checks this with public/protected/private members/methods for C++. This can be used with code-completion to indicate availability/accessibility of completed items.<br>
> <br>
> The patch is against trunk rev. #139681. As always, feedback is welcome.<br>
<br>
Cool! A few comments:<br>
<br>
diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h<br>
index ce762b8..0f7dfea 100644<br>
--- a/include/clang/Sema/Lookup.h<br>
+++ b/include/clang/Sema/Lookup.h<br>
@@ -655,7 +655,7 @@ private:<br>
     /// \param InBaseClass whether this declaration was found in base<br>
     /// class of the context we searched.<br>
     virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, <br>
-                           bool InBaseClass) = 0;<br>
+                           bool InBaseClass, bool Accessible = true) = 0;<br>
   };<br>
 <br>
<br>
I'm not thrilled about adding the Accessible flag here, because I don't want to pay the cost of access checking for every declaration we visit with this generic interface. For example, spell-checking shouldn't pay the cost of access checking for every declaration, because spell-checking only ends up examining a very small number of declarations for further consideration.</div></div></blockquote><span> </span></div><div>This flag is only used so to propagate the value down to the CodeCompletionResult. So, I will see if I can move the access-checking code into the CodeCompletionDeclConsumer.</div><div><br><blockquote type="cite"><div class="msg-quote"><div class="_stretch"><br>
--- a/include/clang/Sema/Sema.h<br>
+++ b/include/clang/Sema/Sema.h<br>
@@ -3648,6 +3648,7 @@ public:<br>
                                     bool ForceCheck = false,<br>
                                     bool ForceUnprivileged = false);<br>
   void CheckLookupAccess(const LookupResult &R);<br>
+  bool IsAccessible(NamedDecl *decl, CXXRecordDecl *Class, bool isUsingDecl);<br>
 <br>
Can the name of this routine have some sort of "Simple" modifier tacked on to it? Full access-checking involves a bunch of madness in member access expressions and such, which we aren't doing here.</div></div></blockquote><span> </span></div><div>Will do that.</div><div><br><blockquote type="cite"><div class="msg-quote"><div class="_stretch"><br>
--- a/tools/c-index-test/c-index-test.c<br>
+++ b/tools/c-index-test/c-index-test.c<br>
@@ -237,6 +237,10 @@ static void PrintCursor(CXTranslationUnit TU, CXCursor Cursor) {<br>
       case CXAvailability_NotAvailable:<br>
         printf(" (unavailable)");<br>
         break;<br>
+<br>
+      case CXAvailability_NotAccessible:<br>
+        printf("  (unaccessible)");<br>
+        break;<br>
     }<br>
     <br>
     if (clang_CXXMethod_isStatic(Cursor))<br>
@@ -1050,6 +1054,10 @@ void print_completion_result(CXCompletionResult *completion_result,<br>
   case CXAvailability_NotAvailable:<br>
     fprintf(file, " (unavailable)");<br>
     break;<br>
+<br>
+  case CXAvailability_NotAccessible:<br>
+    fprintf(file, " (unaccessible)");<br>
+    break;<br>
   }<br>
   fprintf(file, "\n");<br>
 }<br>
-- <br>
1.7.4.4<br>
<br>
"inaccessible" rather than "unaccessible", please.</div></div></blockquote><span> </span></div><div><span>Oops...</span></div><div><span><br></span></div><div><span>-- Erik.</span></div><div><span><br></span></div><div><span><br></span></div></body></html>