diff options
| author | Alp Toker <alp@nuanti.com> | 2014-01-22 07:29:52 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2014-01-22 07:29:52 +0000 |
| commit | 296a4e54995407cf7e3602b29d28ffd001d15e23 (patch) | |
| tree | d39e4e5fb8f8dfa316fdb3e4da74073fb4f1fedb /lib/Sema/SemaCodeComplete.cpp | |
| parent | 8a4d3a8337a6c91f2ae6613f67caff9e04d45811 (diff) | |
| download | clang-296a4e54995407cf7e3602b29d28ffd001d15e23.tar.gz clang-296a4e54995407cf7e3602b29d28ffd001d15e23.tar.bz2 clang-296a4e54995407cf7e3602b29d28ffd001d15e23.tar.xz | |
Introduce and use Decl::getAsFunction() to simplify templated function checks
Lift the getFunctionDecl() utility out of the parser into a general
Decl::getAsFunction() and use it to simplify other parts of the implementation.
Reduce isFunctionOrFunctionTemplate() to a simple type check that works the
same was as the other is* functions and move unwrapping of shadowed decls to
callers so it doesn't get run twice.
Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer.
There's no need to query when we already know the body can't be skipped.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
| -rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 73a758db64..33909c7307 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -660,13 +660,10 @@ QualType clang::getDeclUsageType(ASTContext &C, const NamedDecl *ND) { return C.getObjCInterfaceType(Iface); QualType T; - if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) + if (const FunctionDecl *Function = ND->getAsFunction()) T = Function->getCallResultType(); else if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) T = Method->getSendResultType(); - else if (const FunctionTemplateDecl *FunTmpl = - dyn_cast<FunctionTemplateDecl>(ND)) - T = FunTmpl->getTemplatedDecl()->getCallResultType(); else if (const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND)) T = C.getTypeDeclType(cast<EnumDecl>(Enumerator->getDeclContext())); else if (const ObjCPropertyDecl *Property = dyn_cast<ObjCPropertyDecl>(ND)) @@ -2066,14 +2063,11 @@ static void AddResultTypeChunk(ASTContext &Context, return; // Determine the type of the declaration (if it has a type). - QualType T; - if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) + QualType T; + if (const FunctionDecl *Function = ND->getAsFunction()) T = Function->getResultType(); else if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) T = Method->getResultType(); - else if (const FunctionTemplateDecl *FunTmpl = - dyn_cast<FunctionTemplateDecl>(ND)) - T = FunTmpl->getTemplatedDecl()->getResultType(); else if (const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND)) T = Context.getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext())); else if (isa<UnresolvedUsingValueDecl>(ND)) { |
