r300949 - [index] Take advantage of 'external_source_symbol' attribute for indexing purposes

Argyrios Kyrtzidis via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 20 22:42:46 PDT 2017


Author: akirtzidis
Date: Fri Apr 21 00:42:46 2017
New Revision: 300949

URL: http://llvm.org/viewvc/llvm-project?rev=300949&view=rev
Log:
[index] Take advantage of 'external_source_symbol' attribute for indexing purposes

- Ignore decls marked as 'generated_declaration'
- Include the 'defined_in' in the USR for additional namespacing

Added:
    cfe/trunk/test/Index/Core/external-source-symbol-attr.m
Modified:
    cfe/trunk/include/clang/Index/USRGeneration.h
    cfe/trunk/lib/Index/IndexDecl.cpp
    cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
    cfe/trunk/lib/Index/IndexingContext.cpp
    cfe/trunk/lib/Index/IndexingContext.h
    cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/include/clang/Index/USRGeneration.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/USRGeneration.h?rev=300949&r1=300948&r2=300949&view=diff
==============================================================================
--- cfe/trunk/include/clang/Index/USRGeneration.h (original)
+++ cfe/trunk/include/clang/Index/USRGeneration.h Fri Apr 21 00:42:46 2017
@@ -30,10 +30,13 @@ static inline StringRef getUSRSpacePrefi
 bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf);
 
 /// \brief Generate a USR fragment for an Objective-C class.
-void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS);
+void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
+                             StringRef ExtSymbolDefinedIn = "");
 
 /// \brief Generate a USR fragment for an Objective-C class category.
-void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS);
+void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
+                                StringRef ClsExtSymbolDefinedIn = "",
+                                StringRef CatExtSymbolDefinedIn = "");
 
 /// \brief Generate a USR fragment for an Objective-C instance variable.  The
 /// complete USR can be created by concatenating the USR for the
@@ -48,7 +51,12 @@ void generateUSRForObjCMethod(StringRef
 void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
 
 /// \brief Generate a USR fragment for an Objective-C protocol.
-void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS);
+void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
+                                StringRef ExtSymbolDefinedIn = "");
+
+/// Generate USR fragment for a global (non-nested) enum.
+void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
+                              StringRef ExtSymbolDefinedIn = "");
 
 /// \brief Generate a USR for a macro, including the USR prefix.
 ///

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=300949&r1=300948&r2=300949&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Fri Apr 21 00:42:46 2017
@@ -14,6 +14,13 @@
 using namespace clang;
 using namespace index;
 
+#define TRY_DECL(D,CALL_EXPR)                                                  \
+  do {                                                                         \
+    if (!IndexCtx.shouldIndex(D)) return true;                                 \
+    if (!CALL_EXPR)                                                            \
+      return false;                                                            \
+  } while (0)
+
 #define TRY_TO(CALL_EXPR)                                                      \
   do {                                                                         \
     if (!CALL_EXPR)                                                            \
@@ -120,8 +127,7 @@ public:
                                D->getDeclContext(), 0);
     }
 
-    if (!IndexCtx.handleDecl(D, MethodLoc, Roles, Relations))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D, MethodLoc, Roles, Relations));
     IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
     bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>();
     for (const auto *I : D->parameters()) {
@@ -153,8 +159,7 @@ public:
       }
     }
 
-    if (!IndexCtx.handleDecl(D, Roles, Relations))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D, Roles, Relations));
     handleDeclarator(D);
 
     if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
@@ -189,16 +194,14 @@ public:
   }
 
   bool VisitVarDecl(const VarDecl *D) {
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     handleDeclarator(D);
     IndexCtx.indexBody(D->getInit(), D);
     return true;
   }
 
   bool VisitFieldDecl(const FieldDecl *D) {
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     handleDeclarator(D);
     if (D->isBitField())
       IndexCtx.indexBody(D->getBitWidth(), D);
@@ -212,8 +215,7 @@ public:
       // handled in VisitObjCPropertyImplDecl
       return true;
     }
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     handleDeclarator(D);
     return true;
   }
@@ -224,16 +226,14 @@ public:
   }
 
   bool VisitEnumConstantDecl(const EnumConstantDecl *D) {
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     IndexCtx.indexBody(D->getInitExpr(), D);
     return true;
   }
 
   bool VisitTypedefNameDecl(const TypedefNameDecl *D) {
     if (!D->isTransparentTag()) {
-      if (!IndexCtx.handleDecl(D))
-        return false;
+      TRY_DECL(D, IndexCtx.handleDecl(D));
       IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
     }
     return true;
@@ -273,7 +273,7 @@ public:
 
   bool VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) {
     if (D->isThisDeclarationADefinition()) {
-      TRY_TO(IndexCtx.handleDecl(D));
+      TRY_DECL(D, IndexCtx.handleDecl(D));
       SourceLocation SuperLoc = D->getSuperClassLoc();
       if (auto *SuperD = D->getSuperClass()) {
         bool hasSuperTypedef = false;
@@ -304,7 +304,7 @@ public:
 
   bool VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
     if (D->isThisDeclarationADefinition()) {
-      TRY_TO(IndexCtx.handleDecl(D));
+      TRY_DECL(D, IndexCtx.handleDecl(D));
       TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
                                        /*superLoc=*/SourceLocation()));
       TRY_TO(IndexCtx.indexDeclContext(D));
@@ -323,8 +323,7 @@ public:
     if (Class->isImplicitInterfaceDecl())
       IndexCtx.handleDecl(Class);
 
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
 
     // Visit implicit @synthesize property implementations first as their
     // location is reported at the name of the @implementation block. This
@@ -343,6 +342,8 @@ public:
   }
 
   bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
+    if (!IndexCtx.shouldIndex(D))
+      return true;
     const ObjCInterfaceDecl *C = D->getClassInterface();
     if (!C)
       return true;
@@ -371,8 +372,7 @@ public:
     SourceLocation CategoryLoc = D->getCategoryNameLoc();
     if (!CategoryLoc.isValid())
       CategoryLoc = D->getLocation();
-    if (!IndexCtx.handleDecl(D, CategoryLoc))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D, CategoryLoc));
     IndexCtx.indexDeclContext(D);
     return true;
   }
@@ -394,8 +394,7 @@ public:
     if (ObjCMethodDecl *MD = D->getSetterMethodDecl())
       if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
         handleObjCMethod(MD, D);
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     if (IBOutletCollectionAttr *attr = D->getAttr<IBOutletCollectionAttr>())
       IndexCtx.indexTypeSourceInfo(attr->getInterfaceLoc(), D,
                                    D->getLexicalDeclContext(), false, true);
@@ -416,8 +415,7 @@ public:
       Loc = Container->getLocation();
       Roles |= (SymbolRoleSet)SymbolRole::Implicit;
     }
-    if (!IndexCtx.handleDecl(D, Loc, Roles, Relations))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D, Loc, Roles, Relations));
 
     if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
       return true;
@@ -451,8 +449,7 @@ public:
         } else if (D->getLocation() == IvarLoc) {
           IvarRoles = (SymbolRoleSet)SymbolRole::Implicit;
         }
-        if(!IndexCtx.handleDecl(IvarD, IvarLoc, IvarRoles))
-          return false;
+        TRY_DECL(IvarD, IndexCtx.handleDecl(IvarD, IvarLoc, IvarRoles));
       } else {
         IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr,
                                  D->getDeclContext(), SymbolRoleSet());
@@ -462,8 +459,7 @@ public:
   }
 
   bool VisitNamespaceDecl(const NamespaceDecl *D) {
-    if (!IndexCtx.handleDecl(D))
-      return false;
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     IndexCtx.indexDeclContext(D);
     return true;
   }

Modified: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp?rev=300949&r1=300948&r2=300949&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp Fri Apr 21 00:42:46 2017
@@ -210,6 +210,8 @@ void IndexingContext::indexNestedNameSpe
 
 void IndexingContext::indexTagDecl(const TagDecl *D,
                                    ArrayRef<SymbolRelation> Relations) {
+  if (!shouldIndex(D))
+    return;
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
     return;
 

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=300949&r1=300948&r2=300949&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Fri Apr 21 00:42:46 2017
@@ -17,6 +17,17 @@
 using namespace clang;
 using namespace index;
 
+static bool isGeneratedDecl(const Decl *D) {
+  if (auto *attr = D->getAttr<ExternalSourceSymbolAttr>()) {
+    return attr->getGeneratedDeclaration();
+  }
+  return false;
+}
+
+bool IndexingContext::shouldIndex(const Decl *D) {
+  return !isGeneratedDecl(D);
+}
+
 bool IndexingContext::shouldIndexFunctionLocalSymbols() const {
   return IndexOpts.IndexFunctionLocals;
 }

Modified: cfe/trunk/lib/Index/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.h?rev=300949&r1=300948&r2=300949&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexingContext.h (original)
+++ cfe/trunk/lib/Index/IndexingContext.h Fri Apr 21 00:42:46 2017
@@ -48,6 +48,8 @@ public:
 
   void setASTContext(ASTContext &ctx) { Ctx = &ctx; }
 
+  bool shouldIndex(const Decl *D);
+
   bool shouldSuppressRefs() const {
     return false;
   }

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=300949&r1=300948&r2=300949&view=diff
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Fri Apr 21 00:42:46 2017
@@ -46,6 +46,15 @@ static bool printLoc(llvm::raw_ostream &
   return false;
 }
 
+static StringRef GetExternalSourceContainer(const NamedDecl *D) {
+  if (!D)
+    return StringRef();
+  if (auto *attr = D->getAttr<ExternalSourceSymbolAttr>()) {
+    return attr->getDefinedIn();
+  }
+  return StringRef();
+}
+
 namespace {
 class USRGenerator : public ConstDeclVisitor<USRGenerator> {
   SmallVectorImpl<char> &Buf;
@@ -116,6 +125,8 @@ public:
     return D->getParentFunctionOrMethod() != nullptr;
   }
 
+  void GenExtSymbolContainer(const NamedDecl *D);
+
   /// Generate the string component containing the location of the
   ///  declaration.
   bool GenLoc(const Decl *D, bool IncludeOffset);
@@ -127,13 +138,14 @@ public:
   /// itself.
 
   /// Generate a USR for an Objective-C class.
-  void GenObjCClass(StringRef cls) {
-    generateUSRForObjCClass(cls, Out);
+  void GenObjCClass(StringRef cls, StringRef ext) {
+    generateUSRForObjCClass(cls, Out, ext);
   }
 
   /// Generate a USR for an Objective-C class category.
-  void GenObjCCategory(StringRef cls, StringRef cat) {
-    generateUSRForObjCCategory(cls, cat, Out);
+  void GenObjCCategory(StringRef cls, StringRef cat,
+                       StringRef clsExt, StringRef catExt) {
+    generateUSRForObjCCategory(cls, cat, Out, clsExt, catExt);
   }
 
   /// Generate a USR fragment for an Objective-C property.
@@ -142,8 +154,8 @@ public:
   }
 
   /// Generate a USR for an Objective-C protocol.
-  void GenObjCProtocol(StringRef prot) {
-    generateUSRForObjCProtocol(prot, Out);
+  void GenObjCProtocol(StringRef prot, StringRef ext) {
+    generateUSRForObjCProtocol(prot, Out, ext);
   }
 
   void VisitType(QualType T);
@@ -204,7 +216,11 @@ void USRGenerator::VisitFunctionDecl(con
   if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
     return;
 
+  const unsigned StartSize = Buf.size();
   VisitDeclContext(D->getDeclContext());
+  if (Buf.size() == StartSize)
+    GenExtSymbolContainer(D);
+
   bool IsTemplate = false;
   if (FunctionTemplateDecl *FunTmpl = D->getDescribedFunctionTemplate()) {
     IsTemplate = true;
@@ -382,7 +398,7 @@ void USRGenerator::VisitObjCContainerDec
       llvm_unreachable("Invalid ObjC container.");
     case Decl::ObjCInterface:
     case Decl::ObjCImplementation:
-      GenObjCClass(D->getName());
+      GenObjCClass(D->getName(), GetExternalSourceContainer(D));
       break;
     case Decl::ObjCCategory: {
       const ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(D);
@@ -402,7 +418,9 @@ void USRGenerator::VisitObjCContainerDec
         GenLoc(CD, /*IncludeOffset=*/true);
       }
       else
-        GenObjCCategory(ID->getName(), CD->getName());
+        GenObjCCategory(ID->getName(), CD->getName(),
+                        GetExternalSourceContainer(ID),
+                        GetExternalSourceContainer(CD));
 
       break;
     }
@@ -417,12 +435,16 @@ void USRGenerator::VisitObjCContainerDec
         IgnoreResults = true;
         return;
       }
-      GenObjCCategory(ID->getName(), CD->getName());
+      GenObjCCategory(ID->getName(), CD->getName(),
+                      GetExternalSourceContainer(ID),
+                      GetExternalSourceContainer(CD));
       break;
     }
-    case Decl::ObjCProtocol:
-      GenObjCProtocol(cast<ObjCProtocolDecl>(D)->getName());
+    case Decl::ObjCProtocol: {
+      const ObjCProtocolDecl *PD = cast<ObjCProtocolDecl>(D);
+      GenObjCProtocol(PD->getName(), GetExternalSourceContainer(PD));
       break;
+    }
   }
 }
 
@@ -452,6 +474,8 @@ void USRGenerator::VisitTagDecl(const Ta
       ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
     return;
 
+  GenExtSymbolContainer(D);
+
   D = D->getCanonicalDecl();
   VisitDeclContext(D->getDeclContext());
 
@@ -544,6 +568,12 @@ void USRGenerator::VisitTemplateTypeParm
   GenLoc(D, /*IncludeOffset=*/true);
 }
 
+void USRGenerator::GenExtSymbolContainer(const NamedDecl *D) {
+  StringRef Container = GetExternalSourceContainer(D);
+  if (!Container.empty())
+    Out << "@M@" << Container;
+}
+
 bool USRGenerator::GenLoc(const Decl *D, bool IncludeOffset) {
   if (generatedLoc)
     return IgnoreResults;
@@ -866,12 +896,27 @@ void USRGenerator::VisitTemplateArgument
 // USR generation functions.
 //===----------------------------------------------------------------------===//
 
-void clang::index::generateUSRForObjCClass(StringRef Cls, raw_ostream &OS) {
+void clang::index::generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
+                                           StringRef ExtSymDefinedIn) {
+  if (!ExtSymDefinedIn.empty())
+    OS << "@M@" << ExtSymDefinedIn << '@';
   OS << "objc(cs)" << Cls;
 }
 
 void clang::index::generateUSRForObjCCategory(StringRef Cls, StringRef Cat,
-                                              raw_ostream &OS) {
+                                              raw_ostream &OS,
+                                              StringRef ClsSymDefinedIn,
+                                              StringRef CatSymDefinedIn) {
+  if (!CatSymDefinedIn.empty() || !ClsSymDefinedIn.empty()) {
+    OS << "@M@";
+    if (!CatSymDefinedIn.empty() && !ClsSymDefinedIn.empty())
+      OS << CatSymDefinedIn << '-' << ClsSymDefinedIn;
+    else if (!CatSymDefinedIn.empty())
+      OS << CatSymDefinedIn;
+    else
+      OS << ClsSymDefinedIn;
+    OS << '@';
+  }
   OS << "objc(cy)" << Cls << '@' << Cat;
 }
 
@@ -890,10 +935,20 @@ void clang::index::generateUSRForObjCPro
   OS << (isClassProp ? "(cpy)" : "(py)") << Prop;
 }
 
-void clang::index::generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS) {
+void clang::index::generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
+                                              StringRef ExtSymDefinedIn) {
+  if (!ExtSymDefinedIn.empty())
+    OS << "@M@" << ExtSymDefinedIn << '@';
   OS << "objc(pl)" << Prot;
 }
 
+void clang::index::generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
+                                            StringRef ExtSymDefinedIn) {
+  if (!ExtSymDefinedIn.empty())
+    OS << "@M@" << ExtSymDefinedIn;
+  OS << "@E@" << EnumName;
+}
+
 bool clang::index::generateUSRForDecl(const Decl *D,
                                       SmallVectorImpl<char> &Buf) {
   if (!D)

Added: cfe/trunk/test/Index/Core/external-source-symbol-attr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/external-source-symbol-attr.m?rev=300949&view=auto
==============================================================================
--- cfe/trunk/test/Index/Core/external-source-symbol-attr.m (added)
+++ cfe/trunk/test/Index/Core/external-source-symbol-attr.m Fri Apr 21 00:42:46 2017
@@ -0,0 +1,88 @@
+// RUN: c-index-test core -print-source-symbols -- %s -target x86_64-apple-macosx10.7 | FileCheck %s
+
+#define EXT_DECL(mod_name) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name)))
+#define GEN_DECL(mod_name) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name, generated_declaration)))
+
+// This should not be indexed.
+GEN_DECL("some_module")
+ at interface I1
+// CHECK-NOT: [[@LINE-1]]:12 |
+-(void)method;
+// CHECK-NOT: [[@LINE-1]]:8 |
+ at end
+
+EXT_DECL("some_module")
+ at interface I2
+// CHECK: [[@LINE-1]]:12 | class/ObjC | I2 | c:@M at some_module@objc(cs)I2 | {{.*}} | Decl | rel: 0
+-(void)method;
+// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | method | c:@M at some_module@objc(cs)I2(im)method | -[I2 method] | Decl,Dyn,RelChild | rel: 1
+ at end
+
+void test1(I1 *o) {
+// CHECK: [[@LINE-1]]:12 | class/ObjC | I1 | c:@M at some_module@objc(cs)I1 |
+  [o method];
+  // CHECK: [[@LINE-1]]:6 | instance-method/ObjC | method | c:@M at some_module@objc(cs)I1(im)method |
+}
+
+EXT_DECL("some_module")
+ at protocol ExtProt
+// CHECK: [[@LINE-1]]:11 | protocol/ObjC | ExtProt | c:@M at some_module@objc(pl)ExtProt |
+ at end
+
+ at interface I1(cat)
+// CHECK: [[@LINE-1]]:15 | extension/ObjC | cat | c:@M at some_module@objc(cy)I1 at cat |
+-(void)cat_method;
+// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | cat_method | c:@M at some_module@objc(cs)I1(im)cat_method
+ at end
+
+EXT_DECL("cat_module")
+ at interface I1(cat2)
+// CHECK: [[@LINE-1]]:15 | extension/ObjC | cat2 | c:@M at cat_module-some_module@objc(cy)I1 at cat2 |
+-(void)cat_method2;
+// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | cat_method2 | c:@M at some_module@objc(cs)I1(im)cat_method2
+ at end
+
+#define NS_ENUM(_name, _type) enum _name:_type _name; enum _name : _type
+
+#pragma clang attribute push(GEN_DECL("modname"), apply_to=any(enum, objc_interface, objc_category, objc_protocol))
+
+ at interface I3
+// CHECK-NOT: [[@LINE-1]]:12 |
+-(void)meth;
+// CHECK-NOT: [[@LINE-1]]:8 |
+ at end
+
+ at interface I3(cat)
+// CHECK-NOT: [[@LINE-1]]:12 |
+// CHECK-NOT: [[@LINE-2]]:15 |
+-(void)meth2;
+// CHECK-NOT: [[@LINE-1]]:8 |
+ at end
+
+ at protocol ExtProt2
+// CHECK-NOT: [[@LINE-1]]:11 |
+-(void)meth;
+// CHECK-NOT: [[@LINE-1]]:8 |
+ at end
+
+typedef NS_ENUM(SomeEnum, int) {
+// CHECK-NOT: [[@LINE-1]]:17 |
+  SomeEnumFirst = 0,
+  // CHECK-NOT: [[@LINE-1]]:3 |
+};
+
+#pragma clang attribute pop
+
+void test2(I3 *i3, id<ExtProt2> prot2, SomeEnum some) {
+  // CHECK: [[@LINE-1]]:12 | class/ObjC | I3 | c:@M at modname@objc(cs)I3 |
+  // CHECK: [[@LINE-2]]:23 | protocol/ObjC | ExtProt2 | c:@M at modname@objc(pl)ExtProt2 |
+  // CHECK: [[@LINE-3]]:40 | enum/C | SomeEnum | c:@M at modname@E at SomeEnum |
+  [i3 meth];
+  // CHECK: [[@LINE-1]]:7 | instance-method/ObjC | meth | c:@M at modname@objc(cs)I3(im)meth |
+  [i3 meth2];
+  // CHECK: [[@LINE-1]]:7 | instance-method/ObjC | meth2 | c:@M at modname@objc(cs)I3(im)meth2 |
+  [prot2 meth];
+  // CHECK: [[@LINE-1]]:10 | instance-method/ObjC | meth | c:@M at modname@objc(pl)ExtProt2(im)meth |
+  some = SomeEnumFirst;
+  // CHECK: [[@LINE-1]]:10 | enumerator/C | SomeEnumFirst | c:@M at modname@E at SomeEnum@SomeEnumFirst |
+}




More information about the cfe-commits mailing list