diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-18 15:03:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-18 15:03:34 +0000 |
commit | 4ea8043d6fca75710a6f7a08b1a2f0d8ecf34277 (patch) | |
tree | 56b2ba339a5e5d36c543010a41044fb8bc3bb017 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | 163c58502abf01db880cefb8a6c0b55c88142446 (diff) | |
download | bcm5719-llvm-4ea8043d6fca75710a6f7a08b1a2f0d8ecf34277.tar.gz bcm5719-llvm-4ea8043d6fca75710a6f7a08b1a2f0d8ecf34277.zip |
As threatened previously: consolidate name lookup and the creation of
DeclRefExprs and BlockDeclRefExprs into a single function
Sema::ActOnDeclarationNameExpr, eliminating a bunch of duplicate
lookup-name-and-check-the-result code.
Note that we still have the three parser entry points for identifiers,
operator-function-ids, and conversion-function-ids, since the parser
doesn't (and shouldn't) know about DeclarationNames. This is a Good
Thing (TM), and there will be more entrypoints coming (e.g., for C++
pseudo-destructor expressions).
llvm-svn: 59527
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 71 |
1 files changed, 3 insertions, 68 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index f2c6c3b35b1..5864f222df1 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -33,41 +33,8 @@ Sema::ExprResult Sema::ActOnConversionFunctionExpr(Scope *S, QualType ConvTypeCanon = Context.getCanonicalType(ConvType); DeclarationName ConvName = Context.DeclarationNames.getCXXConversionFunctionName(ConvTypeCanon); - - // We only expect to find a CXXConversionDecl. - Decl *D; - if (SS && !SS->isEmpty()) { - DeclContext *DC = static_cast<DeclContext*>(SS->getScopeRep()); - if (DC == 0) - return true; - D = LookupDecl(ConvName, Decl::IDNS_Ordinary, S, DC); - } else - D = LookupDecl(ConvName, Decl::IDNS_Ordinary, S); - - if (D == 0) { - // If there is no conversion function that converts to this type, - // diagnose the problem. - if (SS && !SS->isEmpty()) - return Diag(OperatorLoc, diag::err_typecheck_no_member, - ConvType.getAsString(), SS->getRange()); - else - return Diag(OperatorLoc, diag::err_no_conv_function, - ConvType.getAsString()); - } - - assert(isa<CXXConversionDecl>(D) && "we had to find a conversion function"); - CXXConversionDecl *Conversion = cast<CXXConversionDecl>(D); - - // check if referencing a declaration with __attribute__((deprecated)). - if (Conversion->getAttr<DeprecatedAttr>()) - Diag(OperatorLoc, diag::warn_deprecated, Conversion->getName()); - - // Only create DeclRefExpr's for valid Decl's. - if (Conversion->isInvalidDecl()) - return true; - - // Create a normal DeclRefExpr. - return new DeclRefExpr(Conversion, Conversion->getType(), OperatorLoc); + return ActOnDeclarationNameExpr(S, OperatorLoc, ConvName, HasTrailingLParen, + SS); } /// ActOnOperatorFunctionIdExpr - Parse a C++ overloaded operator @@ -81,39 +48,7 @@ Sema::ExprResult Sema::ActOnOperatorFunctionIdExpr(Scope *S, bool HasTrailingLParen, const CXXScopeSpec *SS) { DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(Op); - - Decl *D; - if (SS && !SS->isEmpty()) { - DeclContext *DC = static_cast<DeclContext*>(SS->getScopeRep()); - if (DC == 0) - return true; - D = LookupDecl(Name, Decl::IDNS_Ordinary, S, DC); - } else - D = LookupDecl(Name, Decl::IDNS_Ordinary, S); - - if (D == 0) { - // If there is no conversion function that converts to this type, - // diagnose the problem. - if (SS && !SS->isEmpty()) - return Diag(OperatorLoc, diag::err_typecheck_no_member, - Name.getAsString(), SS->getRange()); - else - return Diag(OperatorLoc, diag::err_undeclared_var_use, - Name.getAsString()); - } - - ValueDecl *VD = cast<ValueDecl>(D); - - // check if referencing a declaration with __attribute__((deprecated)). - if (VD->getAttr<DeprecatedAttr>()) - Diag(OperatorLoc, diag::warn_deprecated, Name.getAsString()); - - // Only create DeclRefExpr's for valid Decl's. - if (VD->isInvalidDecl()) - return true; - - // Create a normal DeclRefExpr. - return new DeclRefExpr(VD, VD->getType(), OperatorLoc); + return ActOnDeclarationNameExpr(S, OperatorLoc, Name, HasTrailingLParen, SS); } /// ActOnCXXTypeidOfType - Parse typeid( type-id ). |