[cfe-commits] r161352 - in /cfe/trunk: include/clang/AST/Comment.h include/clang/AST/CommentSema.h lib/AST/Comment.cpp lib/AST/CommentSema.cpp
Dmitri Gribenko
gribozavr at gmail.com
Mon Aug 6 14:31:15 PDT 2012
Author: gribozavr
Date: Mon Aug 6 16:31:15 2012
New Revision: 161352
URL: http://llvm.org/viewvc/llvm-project?rev=161352&view=rev
Log:
Comment AST: DeclInfo: collapse a bunch of boolean flags into an enum.
Modified:
cfe/trunk/include/clang/AST/Comment.h
cfe/trunk/include/clang/AST/CommentSema.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=161352&r1=161351&r2=161352&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Mon Aug 6 16:31:15 2012
@@ -925,7 +925,8 @@
QualType ResultType;
/// Template parameters that can be referenced by \\tparam if \c ThisDecl is
- /// a template.
+ /// a template (\c IsTemplateDecl or \c IsTemplatePartialSpecialization is
+ /// true).
const TemplateParameterList *TemplateParameters;
/// A simplified description of \c ThisDecl kind that should be good enough
@@ -963,6 +964,14 @@
TypedefKind
};
+ /// What kind of template specialization \c ThisDecl is.
+ enum TemplateDeclKind {
+ NotTemplate,
+ Template,
+ TemplateSpecialization,
+ TemplatePartialSpecialization
+ };
+
/// If false, only \c ThisDecl is valid.
unsigned IsFilled : 1;
@@ -970,14 +979,7 @@
unsigned Kind : 3;
/// Is \c ThisDecl a template declaration.
- unsigned IsTemplateDecl : 1;
-
- /// Is \c ThisDecl a template specialization.
- unsigned IsTemplateSpecialization : 1;
-
- /// Is \c ThisDecl a template partial specialization.
- /// Never true if \c IsFunctionDecl is true.
- unsigned IsTemplatePartialSpecialization : 1;
+ unsigned TemplateKind : 2;
/// Is \c ThisDecl an ObjCMethodDecl.
unsigned IsObjCMethod : 1;
@@ -997,6 +999,10 @@
DeclKind getKind() const LLVM_READONLY {
return static_cast<DeclKind>(Kind);
}
+
+ TemplateDeclKind getTemplateKind() const LLVM_READONLY {
+ return static_cast<TemplateDeclKind>(TemplateKind);
+ }
};
/// A full comment attached to a declaration, contains block content.
Modified: cfe/trunk/include/clang/AST/CommentSema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=161352&r1=161351&r2=161352&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentSema.h (original)
+++ cfe/trunk/include/clang/AST/CommentSema.h Mon Aug 6 16:31:15 2012
@@ -188,7 +188,7 @@
void checkBlockCommandDuplicate(const BlockCommandComment *Command);
bool isFunctionDecl();
- bool isTemplateDecl();
+ bool isTemplateOrSpecialization();
ArrayRef<const ParmVarDecl *> getParamVars();
Modified: cfe/trunk/lib/AST/Comment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=161352&r1=161351&r2=161352&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Mon Aug 6 16:31:15 2012
@@ -142,9 +142,7 @@
// Set defaults.
Kind = OtherKind;
- IsTemplateDecl = false;
- IsTemplateSpecialization = false;
- IsTemplatePartialSpecialization = false;
+ TemplateKind = NotTemplate;
IsObjCMethod = false;
IsInstanceMethod = false;
IsClassMethod = false;
@@ -174,8 +172,7 @@
ResultType = FD->getResultType();
unsigned NumLists = FD->getNumTemplateParameterLists();
if (NumLists != 0) {
- IsTemplateDecl = true;
- IsTemplateSpecialization = true;
+ TemplateKind = TemplateSpecialization;
TemplateParameters =
FD->getTemplateParameterList(NumLists - 1);
}
@@ -202,7 +199,7 @@
case Decl::FunctionTemplate: {
const FunctionTemplateDecl *FTD = cast<FunctionTemplateDecl>(ThisDecl);
Kind = FunctionKind;
- IsTemplateDecl = true;
+ TemplateKind = Template;
const FunctionDecl *FD = FTD->getTemplatedDecl();
ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(),
FD->getNumParams());
@@ -213,7 +210,7 @@
case Decl::ClassTemplate: {
const ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(ThisDecl);
Kind = ClassKind;
- IsTemplateDecl = true;
+ TemplateKind = Template;
TemplateParameters = CTD->getTemplateParameters();
break;
}
@@ -221,15 +218,13 @@
const ClassTemplatePartialSpecializationDecl *CTPSD =
cast<ClassTemplatePartialSpecializationDecl>(ThisDecl);
Kind = ClassKind;
- IsTemplateDecl = true;
- IsTemplatePartialSpecialization = true;
+ TemplateKind = TemplatePartialSpecialization;
TemplateParameters = CTPSD->getTemplateParameters();
break;
}
case Decl::ClassTemplateSpecialization:
Kind = ClassKind;
- IsTemplateDecl = true;
- IsTemplateSpecialization = true;
+ TemplateKind = TemplateSpecialization;
break;
case Decl::Record:
case Decl::CXXRecord:
@@ -251,7 +246,7 @@
case Decl::TypeAliasTemplate: {
const TypeAliasTemplateDecl *TAT = cast<TypeAliasTemplateDecl>(ThisDecl);
Kind = TypedefKind;
- IsTemplateDecl = true;
+ TemplateKind = Template;
TemplateParameters = TAT->getTemplateParameters();
break;
}
Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=161352&r1=161351&r2=161352&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Mon Aug 6 16:31:15 2012
@@ -205,7 +205,7 @@
TParamCommandComment *Command =
new (Allocator) TParamCommandComment(LocBegin, LocEnd, Name);
- if (!isTemplateDecl())
+ if (!isTemplateOrSpecialization())
Diag(Command->getLocation(),
diag::warn_doc_tparam_not_attached_to_a_template_decl)
<< Command->getCommandNameRange();
@@ -226,7 +226,7 @@
Arg);
Command->setArgs(llvm::makeArrayRef(A, 1));
- if (!isTemplateDecl()) {
+ if (!isTemplateOrSpecialization()) {
// We already warned that this \\tparam is not attached to a template decl.
return;
}
@@ -536,12 +536,12 @@
return ThisDeclInfo->getKind() == DeclInfo::FunctionKind;
}
-bool Sema::isTemplateDecl() {
+bool Sema::isTemplateOrSpecialization() {
if (!ThisDeclInfo)
return false;
if (!ThisDeclInfo->IsFilled)
inspectThisDecl();
- return ThisDeclInfo->IsTemplateDecl;
+ return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate;
}
ArrayRef<const ParmVarDecl *> Sema::getParamVars() {
More information about the cfe-commits
mailing list