[cfe-commits] [Patch][review-request]Fix for 'using namespace' within function body in static analyzer

Jim Goodnow II jim at thegoodnows.net
Mon Feb 14 04:45:08 PST 2011


The following code, when compiled with 'clang -cc1 -analyze 
-analyzer-check-objc-mem -cfg-dump' will generate a 'Subtype of 
ScopeDecl not handled error', I'm not sure where a test case should 
go for this?

namespace fum {
   int i = 3;
};

void foo() {
   using namespace fum;

   int x = i;
}

Patch:

Index: include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
===================================================================
--- include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h	(revision 125488)
+++ include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h	(working copy)
@@ -66,6 +66,7 @@
          DISPATCH_CASE(Record)    // FIXME: Refine.  VisitStructDecl?
          DISPATCH_CASE(CXXRecord)
          DISPATCH_CASE(Enum)
+        DISPATCH_CASE(UsingDirective)
        default:
          assert(false && "Subtype of ScopedDecl not handled.");
      }
@@ -85,6 +86,7 @@
    DEFAULT_DISPATCH(ObjCMethod)
    DEFAULT_DISPATCH(ObjCProtocol)
    DEFAULT_DISPATCH(ObjCCategory)
+  DEFAULT_DISPATCH(UsingDirective)

    void VisitCXXRecordDecl(CXXRecordDecl *D) {
      static_cast<ImplClass*>(this)->VisitRecordDecl(D);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: using.patch
Type: application/octet-stream
Size: 820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110214/e8505205/attachment.obj>


More information about the cfe-commits mailing list