summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Comment.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-08-01 23:08:09 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-08-01 23:08:09 +0000
commit527ab21112b2bb19258deb1780dcda5b53284f72 (patch)
treebb9333b680cbccba97198d2716a700a28432f6a6 /clang/lib/AST/Comment.cpp
parent3a770d0fe4bef3fdca94e81ab5d9c1bc78810772 (diff)
downloadbcm5719-llvm-527ab21112b2bb19258deb1780dcda5b53284f72.tar.gz
bcm5719-llvm-527ab21112b2bb19258deb1780dcda5b53284f72.zip
Comment AST: add DeclInfo to store information about the declaration. Sema was
already extracting most of this, but discarding at the end of semantic analysis. llvm-svn: 161140
Diffstat (limited to 'clang/lib/AST/Comment.cpp')
-rw-r--r--clang/lib/AST/Comment.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 82dbed47f8a..15b80c64554 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -8,6 +8,9 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/Comment.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclTemplate.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
@@ -134,5 +137,66 @@ const char *ParamCommandComment::getDirectionAsString(PassDirection D) {
llvm_unreachable("unknown PassDirection");
}
+void DeclInfo::fill() {
+ assert(!IsFilled);
+
+ // Set defaults.
+ IsFunctionDecl = false;
+ IsTemplateDecl = false;
+ IsTemplateSpecialization = false;
+ IsTemplatePartialSpecialization = false;
+ IsInstanceMethod = false;
+ IsClassMethod = false;
+ ParamVars = ArrayRef<const ParmVarDecl *>();
+ TemplateParameters = NULL;
+
+ if (!ThisDecl) {
+ // Defaults are OK.
+ } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ThisDecl)) {
+ IsFunctionDecl = true;
+ ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(),
+ FD->getNumParams());
+ unsigned NumLists = FD->getNumTemplateParameterLists();
+ if (NumLists != 0) {
+ IsTemplateDecl = true;
+ IsTemplateSpecialization = true;
+ TemplateParameters =
+ FD->getTemplateParameterList(NumLists - 1);
+ }
+
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+ IsInstanceMethod = MD->isInstance();
+ IsClassMethod = !IsInstanceMethod;
+ }
+ } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ThisDecl)) {
+ IsFunctionDecl = true;
+ 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;
+ IsTemplateDecl = true;
+ const FunctionDecl *FD = FTD->getTemplatedDecl();
+ ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(),
+ FD->getNumParams());
+ TemplateParameters = FTD->getTemplateParameters();
+ } else if (const ClassTemplateDecl *CTD =
+ dyn_cast<ClassTemplateDecl>(ThisDecl)) {
+ IsTemplateDecl = true;
+ TemplateParameters = CTD->getTemplateParameters();
+ } else if (const ClassTemplatePartialSpecializationDecl *CTPSD =
+ dyn_cast<ClassTemplatePartialSpecializationDecl>(ThisDecl)) {
+ IsTemplateDecl = true;
+ IsTemplatePartialSpecialization = true;
+ TemplateParameters = CTPSD->getTemplateParameters();
+ } else if (isa<ClassTemplateSpecializationDecl>(ThisDecl)) {
+ IsTemplateDecl = true;
+ IsTemplateSpecialization = true;
+ }
+ IsFilled = true;
+}
+
} // end namespace comments
} // end namespace clang
OpenPOWER on IntegriCloud