Rework the traversal of Objective-C categories and extensions to
authorDouglas Gregor <dgregor@apple.com>
Wed, 16 Jan 2013 23:00:23 +0000 (23:00 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 16 Jan 2013 23:00:23 +0000 (23:00 +0000)
commit048fbfa302717d66b549f77469500408ca682117
tree9580828c2e508b6ad946be861a75c9c62cab5da8
parente8baf33712857bdb1deeb6100087cc3bc93861ea
Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.

The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:

  visible_categories_iterator: Iterates over all visible categories
  and extensions, hiding any that have their "hidden" bit set. This is
  by far the most commonly used iterator.

  known_categories_iterator: Iterates over all categories and
  extensions, ignoring the "hidden" bit. This tends to be used for
  redeclaration-like traversals.

  visible_extensions_iterator: Iterates over all visible extensions,
  hiding any that have their "hidden" bit set.

  known_extensions_iterator: Iterates over all extensions, whether
  they are visible to normal name lookup or not.

The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.

Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.

Part two of <rdar://problem/10634711>.

llvm-svn: 172665
23 files changed:
clang/include/clang/AST/DeclObjC.h
clang/lib/ARCMigrate/TransProperties.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/DumpXML.cpp
clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
clang/lib/Rewrite/Frontend/RewriteObjC.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
clang/test/Modules/Inputs/category_left_sub.h [new file with mode: 0644]
clang/test/Modules/Inputs/category_right_sub.h [new file with mode: 0644]
clang/test/Modules/Inputs/category_top.h
clang/test/Modules/Inputs/module.map
clang/test/Modules/objc-categories.m