r286680 - [index] Rename SymbolSubKind -> SymbolProperty, NFC.

Argyrios Kyrtzidis via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 11 15:49:55 PST 2016


Author: akirtzidis
Date: Fri Nov 11 17:49:55 2016
New Revision: 286680

URL: http://llvm.org/viewvc/llvm-project?rev=286680&view=rev
Log:
[index] Rename SymbolSubKind -> SymbolProperty, NFC.

This better reflects what it represents.

Modified:
    cfe/trunk/include/clang/Index/IndexSymbol.h
    cfe/trunk/lib/Index/IndexSymbol.cpp
    cfe/trunk/tools/c-index-test/core_main.cpp
    cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=286680&r1=286679&r2=286680&view=diff
==============================================================================
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Fri Nov 11 17:49:55 2016
@@ -59,7 +59,8 @@ enum class SymbolLanguage {
   CXX,
 };
 
-enum class SymbolSubKind : uint8_t {
+/// Set of properties that provide additional info about a symbol.
+enum class SymbolProperty : uint8_t {
   Generic                       = 1 << 0,
   TemplatePartialSpecialization = 1 << 1,
   TemplateSpecialization        = 1 << 2,
@@ -68,8 +69,8 @@ enum class SymbolSubKind : uint8_t {
   IBOutletCollection            = 1 << 5,
   GKInspectable                 = 1 << 6,
 };
-static const unsigned SymbolSubKindBitNum = 7;
-typedef unsigned SymbolSubKindSet;
+static const unsigned SymbolPropertyBitNum = 7;
+typedef unsigned SymbolPropertySet;
 
 /// Set of roles that are attributed to symbol occurrences.
 enum class SymbolRole : uint16_t {
@@ -106,7 +107,7 @@ struct SymbolRelation {
 
 struct SymbolInfo {
   SymbolKind Kind;
-  SymbolSubKindSet SubKinds;
+  SymbolPropertySet Properties;
   SymbolLanguage Lang;
 };
 
@@ -122,9 +123,9 @@ bool printSymbolName(const Decl *D, cons
 StringRef getSymbolKindString(SymbolKind K);
 StringRef getSymbolLanguageString(SymbolLanguage K);
 
-void applyForEachSymbolSubKind(SymbolSubKindSet SubKinds,
-                            llvm::function_ref<void(SymbolSubKind)> Fn);
-void printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS);
+void applyForEachSymbolProperty(SymbolPropertySet Props,
+                            llvm::function_ref<void(SymbolProperty)> Fn);
+void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
 
 } // namespace index
 } // namespace clang

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=286680&r1=286679&r2=286680&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Fri Nov 11 17:49:55 2016
@@ -40,12 +40,12 @@ static bool isUnitTest(const ObjCMethodD
   return isUnitTestCase(D->getClassInterface());
 }
 
-static void checkForIBOutlets(const Decl *D, SymbolSubKindSet &SubKindSet) {
+static void checkForIBOutlets(const Decl *D, SymbolPropertySet &PropSet) {
   if (D->hasAttr<IBOutletAttr>()) {
-    SubKindSet |= (unsigned)SymbolSubKind::IBAnnotated;
+    PropSet |= (unsigned)SymbolProperty::IBAnnotated;
   } else if (D->hasAttr<IBOutletCollectionAttr>()) {
-    SubKindSet |= (unsigned)SymbolSubKind::IBAnnotated;
-    SubKindSet |= (unsigned)SymbolSubKind::IBOutletCollection;
+    PropSet |= (unsigned)SymbolProperty::IBAnnotated;
+    PropSet |= (unsigned)SymbolProperty::IBOutletCollection;
   }
 }
 
@@ -53,7 +53,7 @@ SymbolInfo index::getSymbolInfo(const De
   assert(D);
   SymbolInfo Info;
   Info.Kind = SymbolKind::Unknown;
-  Info.SubKinds = SymbolSubKindSet();
+  Info.Properties = SymbolPropertySet();
   Info.Lang = SymbolLanguage::C;
 
   if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
@@ -78,17 +78,17 @@ SymbolInfo index::getSymbolInfo(const De
       if (!CXXRec->isCLike()) {
         Info.Lang = SymbolLanguage::CXX;
         if (CXXRec->getDescribedClassTemplate()) {
-          Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+          Info.Properties |= (unsigned)SymbolProperty::Generic;
         }
       }
     }
 
     if (isa<ClassTemplatePartialSpecializationDecl>(D)) {
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
-      Info.SubKinds |= (unsigned)SymbolSubKind::TemplatePartialSpecialization;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
     } else if (isa<ClassTemplateSpecializationDecl>(D)) {
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
-      Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
     }
 
   } else if (auto *VD = dyn_cast<VarDecl>(D)) {
@@ -99,15 +99,15 @@ SymbolInfo index::getSymbolInfo(const De
     }
     if (isa<VarTemplatePartialSpecializationDecl>(D)) {
       Info.Lang = SymbolLanguage::CXX;
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
-      Info.SubKinds |= (unsigned)SymbolSubKind::TemplatePartialSpecialization;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
     } else if (isa<VarTemplateSpecializationDecl>(D)) {
       Info.Lang = SymbolLanguage::CXX;
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
-      Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
     } else if (VD->getDescribedVarTemplate()) {
       Info.Lang = SymbolLanguage::CXX;
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
     }
 
   } else {
@@ -138,7 +138,7 @@ SymbolInfo index::getSymbolInfo(const De
       if (!ClsD)
         ClsD = cast<ObjCImplementationDecl>(D)->getClassInterface();
       if (isUnitTestCase(ClsD))
-        Info.SubKinds |= (unsigned)SymbolSubKind::UnitTest;
+        Info.Properties |= (unsigned)SymbolProperty::UnitTest;
       break;
     }
     case Decl::ObjCProtocol:
@@ -157,23 +157,23 @@ SymbolInfo index::getSymbolInfo(const De
         Info.Kind = SymbolKind::ClassMethod;
       Info.Lang = SymbolLanguage::ObjC;
       if (isUnitTest(cast<ObjCMethodDecl>(D)))
-        Info.SubKinds |= (unsigned)SymbolSubKind::UnitTest;
+        Info.Properties |= (unsigned)SymbolProperty::UnitTest;
       if (D->hasAttr<IBActionAttr>())
-        Info.SubKinds |= (unsigned)SymbolSubKind::IBAnnotated;
+        Info.Properties |= (unsigned)SymbolProperty::IBAnnotated;
       break;
     case Decl::ObjCProperty:
       Info.Kind = SymbolKind::InstanceProperty;
       Info.Lang = SymbolLanguage::ObjC;
-      checkForIBOutlets(D, Info.SubKinds);
+      checkForIBOutlets(D, Info.Properties);
       if (auto *Annot = D->getAttr<AnnotateAttr>()) {
         if (Annot->getAnnotation() == "gk_inspectable")
-          Info.SubKinds |= (unsigned)SymbolSubKind::GKInspectable;
+          Info.Properties |= (unsigned)SymbolProperty::GKInspectable;
       }
       break;
     case Decl::ObjCIvar:
       Info.Kind = SymbolKind::Field;
       Info.Lang = SymbolLanguage::ObjC;
-      checkForIBOutlets(D, Info.SubKinds);
+      checkForIBOutlets(D, Info.Properties);
       break;
     case Decl::Namespace:
       Info.Kind = SymbolKind::Namespace;
@@ -206,12 +206,12 @@ SymbolInfo index::getSymbolInfo(const De
     }
     case Decl::ClassTemplate:
       Info.Kind = SymbolKind::Class;
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
       Info.Lang = SymbolLanguage::CXX;
       break;
     case Decl::FunctionTemplate:
       Info.Kind = SymbolKind::Function;
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
       Info.Lang = SymbolLanguage::CXX;
       if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(
                            cast<FunctionTemplateDecl>(D)->getTemplatedDecl())) {
@@ -232,7 +232,7 @@ SymbolInfo index::getSymbolInfo(const De
     case Decl::TypeAliasTemplate:
       Info.Kind = SymbolKind::TypeAlias;
       Info.Lang = SymbolLanguage::CXX;
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
       break;
     case Decl::TypeAlias:
       Info.Kind = SymbolKind::TypeAlias;
@@ -249,12 +249,12 @@ SymbolInfo index::getSymbolInfo(const De
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     if (FD->getTemplatedKind() ==
           FunctionDecl::TK_FunctionTemplateSpecialization) {
-      Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
-      Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
+      Info.Properties |= (unsigned)SymbolProperty::Generic;
+      Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
     }
   }
 
-  if (Info.SubKinds & (unsigned)SymbolSubKind::Generic)
+  if (Info.Properties & (unsigned)SymbolProperty::Generic)
     Info.Lang = SymbolLanguage::CXX;
 
   return Info;
@@ -372,38 +372,38 @@ StringRef index::getSymbolLanguageString
   llvm_unreachable("invalid symbol language kind");
 }
 
-void index::applyForEachSymbolSubKind(SymbolSubKindSet SubKinds,
-                                  llvm::function_ref<void(SymbolSubKind)> Fn) {
-#define APPLY_FOR_SUBKIND(K) \
-  if (SubKinds & (unsigned)SymbolSubKind::K) \
-    Fn(SymbolSubKind::K)
-
-  APPLY_FOR_SUBKIND(Generic);
-  APPLY_FOR_SUBKIND(TemplatePartialSpecialization);
-  APPLY_FOR_SUBKIND(TemplateSpecialization);
-  APPLY_FOR_SUBKIND(UnitTest);
-  APPLY_FOR_SUBKIND(IBAnnotated);
-  APPLY_FOR_SUBKIND(IBOutletCollection);
-  APPLY_FOR_SUBKIND(GKInspectable);
+void index::applyForEachSymbolProperty(SymbolPropertySet Props,
+                                  llvm::function_ref<void(SymbolProperty)> Fn) {
+#define APPLY_FOR_PROPERTY(K) \
+  if (Props & (unsigned)SymbolProperty::K) \
+    Fn(SymbolProperty::K)
+
+  APPLY_FOR_PROPERTY(Generic);
+  APPLY_FOR_PROPERTY(TemplatePartialSpecialization);
+  APPLY_FOR_PROPERTY(TemplateSpecialization);
+  APPLY_FOR_PROPERTY(UnitTest);
+  APPLY_FOR_PROPERTY(IBAnnotated);
+  APPLY_FOR_PROPERTY(IBOutletCollection);
+  APPLY_FOR_PROPERTY(GKInspectable);
 
-#undef APPLY_FOR_SUBKIND
+#undef APPLY_FOR_PROPERTY
 }
 
-void index::printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS) {
+void index::printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS) {
   bool VisitedOnce = false;
-  applyForEachSymbolSubKind(SubKinds, [&](SymbolSubKind SubKind) {
+  applyForEachSymbolProperty(Props, [&](SymbolProperty Prop) {
     if (VisitedOnce)
       OS << ',';
     else
       VisitedOnce = true;
-    switch (SubKind) {
-    case SymbolSubKind::Generic: OS << "Gen"; break;
-    case SymbolSubKind::TemplatePartialSpecialization: OS << "TPS"; break;
-    case SymbolSubKind::TemplateSpecialization: OS << "TS"; break;
-    case SymbolSubKind::UnitTest: OS << "test"; break;
-    case SymbolSubKind::IBAnnotated: OS << "IB"; break;
-    case SymbolSubKind::IBOutletCollection: OS << "IBColl"; break;
-    case SymbolSubKind::GKInspectable: OS << "GKI"; break;
+    switch (Prop) {
+    case SymbolProperty::Generic: OS << "Gen"; break;
+    case SymbolProperty::TemplatePartialSpecialization: OS << "TPS"; break;
+    case SymbolProperty::TemplateSpecialization: OS << "TS"; break;
+    case SymbolProperty::UnitTest: OS << "test"; break;
+    case SymbolProperty::IBAnnotated: OS << "IB"; break;
+    case SymbolProperty::IBOutletCollection: OS << "IBColl"; break;
+    case SymbolProperty::GKInspectable: OS << "GKI"; break;
     }
   });
 }

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=286680&r1=286679&r2=286680&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Fri Nov 11 17:49:55 2016
@@ -167,9 +167,9 @@ static bool printSourceSymbols(ArrayRef<
 
 static void printSymbolInfo(SymbolInfo SymInfo, raw_ostream &OS) {
   OS << getSymbolKindString(SymInfo.Kind);
-  if (SymInfo.SubKinds) {
+  if (SymInfo.Properties) {
     OS << '(';
-    printSymbolSubKinds(SymInfo.SubKinds, OS);
+    printSymbolProperties(SymInfo.Properties, OS);
     OS << ')';
   }
   OS << '/' << getSymbolLanguageString(SymInfo.Lang);

Modified: cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp?rev=286680&r1=286679&r2=286680&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp (original)
+++ cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp Fri Nov 11 17:49:55 2016
@@ -1142,7 +1142,7 @@ void CXIndexDataConsumer::translateLoc(S
 
 static CXIdxEntityKind getEntityKindFromSymbolKind(SymbolKind K, SymbolLanguage L);
 static CXIdxEntityCXXTemplateKind
-getEntityKindFromSymbolSubKinds(SymbolSubKindSet K);
+getEntityKindFromSymbolProperties(SymbolPropertySet K);
 static CXIdxEntityLanguage getEntityLangFromSymbolLang(SymbolLanguage L);
 
 void CXIndexDataConsumer::getEntityInfo(const NamedDecl *D,
@@ -1158,7 +1158,7 @@ void CXIndexDataConsumer::getEntityInfo(
 
   SymbolInfo SymInfo = getSymbolInfo(D);
   EntityInfo.kind = getEntityKindFromSymbolKind(SymInfo.Kind, SymInfo.Lang);
-  EntityInfo.templateKind = getEntityKindFromSymbolSubKinds(SymInfo.SubKinds);
+  EntityInfo.templateKind = getEntityKindFromSymbolProperties(SymInfo.Properties);
   EntityInfo.lang = getEntityLangFromSymbolLang(SymInfo.Lang);
 
   if (D->hasAttrs()) {
@@ -1298,12 +1298,12 @@ static CXIdxEntityKind getEntityKindFrom
 }
 
 static CXIdxEntityCXXTemplateKind
-getEntityKindFromSymbolSubKinds(SymbolSubKindSet K) {
-  if (K & (unsigned)SymbolSubKind::TemplatePartialSpecialization)
+getEntityKindFromSymbolProperties(SymbolPropertySet K) {
+  if (K & (unsigned)SymbolProperty::TemplatePartialSpecialization)
     return CXIdxEntity_TemplatePartialSpecialization;
-  if (K & (unsigned)SymbolSubKind::TemplateSpecialization)
+  if (K & (unsigned)SymbolProperty::TemplateSpecialization)
     return CXIdxEntity_TemplateSpecialization;
-  if (K & (unsigned)SymbolSubKind::Generic)
+  if (K & (unsigned)SymbolProperty::Generic)
     return CXIdxEntity_Template;
   return CXIdxEntity_NonTemplate;
 }




More information about the cfe-commits mailing list