[cfe-commits] r161217 - in /cfe/trunk: include/clang/AST/Comment.h lib/AST/Comment.cpp lib/AST/CommentSema.cpp
Dmitri Gribenko
gribozavr at gmail.com
Thu Aug 2 14:45:39 PDT 2012
Author: gribozavr
Date: Thu Aug 2 16:45:39 2012
New Revision: 161217
URL: http://llvm.org/viewvc/llvm-project?rev=161217&view=rev
Log:
Comments AST: refactor DeclInfo to use an enum for decl kind instead of
separate flags.
Modified:
cfe/trunk/include/clang/AST/Comment.h
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/lib/AST/CommentSema.cpp
Modified: cfe/trunk/include/clang/AST/Comment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=161217&r1=161216&r2=161217&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Aug 2 16:45:39 2012
@@ -923,14 +923,43 @@
/// a template.
const TemplateParameterList *TemplateParameters;
+ /// A simplified description of \c ThisDecl kind that should be good enough
+ /// for documentation rendering purposes.
+ enum DeclKind {
+ /// Something that we consider a "function":
+ /// \li function,
+ /// \li function template,
+ /// \li function template specialization,
+ /// \li member function,
+ /// \li member function template,
+ /// \li member function template specialization,
+ /// \li ObjC method.
+ FunctionKind,
+
+ /// Something that we consider a "class":
+ /// \li class/struct,
+ /// \li class template,
+ /// \li class template (partial) specialization.
+ ClassKind,
+
+ /// Something that we consider a "variable":
+ /// \li namespace scope variables;
+ /// \li static and non-static class data members.
+ VariableKind,
+
+ /// A C++ namespace.
+ NamespaceKind,
+
+ /// A C++ typedef-name (a 'typedef' decl specifier or alias-declaration),
+ /// see \c TypedefNameDecl.
+ TypedefKind
+ };
+
/// If false, only \c ThisDecl is valid.
unsigned IsFilled : 1;
- /// Is \c ThisDecl something that we consider a "function".
- unsigned IsFunctionDecl : 1;
-
- /// Is \c ThisDecl something that we consider a "class".
- unsigned IsClassDecl : 1;
+ /// Simplified kind of \c ThisDecl, see\c DeclKind enum.
+ unsigned Kind : 3;
/// Is \c ThisDecl a template declaration.
unsigned IsTemplateDecl : 1;
@@ -953,6 +982,10 @@
unsigned IsClassMethod : 1;
void fill();
+
+ DeclKind getKind() const LLVM_READONLY {
+ return static_cast<DeclKind>(Kind);
+ }
};
/// A full comment attached to a declaration, contains block content.
Modified: cfe/trunk/lib/AST/Comment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=161217&r1=161216&r2=161217&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Thu Aug 2 16:45:39 2012
@@ -141,7 +141,7 @@
assert(!IsFilled);
// Set defaults.
- IsFunctionDecl = false;
+ Kind = FunctionKind;
IsTemplateDecl = false;
IsTemplateSpecialization = false;
IsTemplatePartialSpecialization = false;
@@ -153,7 +153,7 @@
if (!ThisDecl) {
// Defaults are OK.
} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ThisDecl)) {
- IsFunctionDecl = true;
+ Kind = FunctionKind;
ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(),
FD->getNumParams());
unsigned NumLists = FD->getNumTemplateParameterLists();
@@ -169,14 +169,14 @@
IsClassMethod = !IsInstanceMethod;
}
} else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ThisDecl)) {
- IsFunctionDecl = true;
+ Kind = FunctionKind;
ParamVars = ArrayRef<const ParmVarDecl *>(MD->param_begin(),
MD->param_size());
IsInstanceMethod = MD->isInstanceMethod();
IsClassMethod = !IsInstanceMethod;
} else if (const FunctionTemplateDecl *FTD =
dyn_cast<FunctionTemplateDecl>(ThisDecl)) {
- IsFunctionDecl = true;
+ Kind = FunctionKind;
IsTemplateDecl = true;
const FunctionDecl *FD = FTD->getTemplatedDecl();
ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(),
@@ -184,18 +184,30 @@
TemplateParameters = FTD->getTemplateParameters();
} else if (const ClassTemplateDecl *CTD =
dyn_cast<ClassTemplateDecl>(ThisDecl)) {
+ Kind = ClassKind;
IsTemplateDecl = true;
TemplateParameters = CTD->getTemplateParameters();
} else if (const ClassTemplatePartialSpecializationDecl *CTPSD =
dyn_cast<ClassTemplatePartialSpecializationDecl>(ThisDecl)) {
+ Kind = ClassKind;
IsTemplateDecl = true;
IsTemplatePartialSpecialization = true;
TemplateParameters = CTPSD->getTemplateParameters();
} else if (isa<ClassTemplateSpecializationDecl>(ThisDecl)) {
+ Kind = ClassKind;
IsTemplateDecl = true;
IsTemplateSpecialization = true;
+ } else if (isa<RecordDecl>(ThisDecl)) {
+ Kind = ClassKind;
+ } else if (isa<VarDecl>(ThisDecl) || isa<FieldDecl>(ThisDecl)) {
+ Kind = VariableKind;
+ } else if (isa<NamespaceDecl>(ThisDecl)) {
+ Kind = NamespaceKind;
+ } else if (isa<TypedefNameDecl>(ThisDecl)) {
+ Kind = TypedefKind;
} else if (const TypeAliasTemplateDecl *TAT =
dyn_cast<TypeAliasTemplateDecl>(ThisDecl)) {
+ Kind = TypedefKind;
IsTemplateDecl = true;
TemplateParameters = TAT->getTemplateParameters();
}
@@ -204,3 +216,4 @@
} // end namespace comments
} // end namespace clang
+
Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=161217&r1=161216&r2=161217&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Thu Aug 2 16:45:39 2012
@@ -477,7 +477,7 @@
return false;
if (!ThisDeclInfo->IsFilled)
inspectThisDecl();
- return ThisDeclInfo->IsFunctionDecl;
+ return ThisDeclInfo->getKind() == DeclInfo::FunctionKind;
}
bool Sema::isTemplateDecl() {
More information about the cfe-commits
mailing list