diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-12-04 23:50:19 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-12-04 23:50:19 +0000 | 
| commit | 79413956d48b07c17b9600b8433089c0784b9fd6 (patch) | |
| tree | 7d322436f511e0aaa753f424d90ab0d609ce2aee /clang/lib/Sema/SemaExpr.cpp | |
| parent | 2ca529ce61f63caed2484b7ee19018df63d7cd12 (diff) | |
| download | bcm5719-llvm-79413956d48b07c17b9600b8433089c0784b9fd6.tar.gz bcm5719-llvm-79413956d48b07c17b9600b8433089c0784b9fd6.zip | |
change getCurFunctionDecl to skip through Block contexts to find
the containing block.  Introduce a new getCurFunctionOrMethodDecl
method to check to see if we're in a function or objc method.
Minor cleanups to other related places.  This fixes rdar://6405429.
llvm-svn: 60564
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 8 | 
1 files changed, 4 insertions, 4 deletions
| diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5aaa0dbc2f4..ec86b9f2a6b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -505,14 +505,14 @@ Sema::ExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,    }    // Verify that this is in a function context. -  if (getCurFunctionDecl() == 0 && getCurMethodDecl() == 0) +  if (getCurFunctionOrMethodDecl() == 0)      return Diag(Loc, diag::err_predef_outside_function);    // Pre-defined identifiers are of type char[x], where x is the length of the    // string.    unsigned Length; -  if (getCurFunctionDecl()) -    Length = getCurFunctionDecl()->getIdentifier()->getLength(); +  if (FunctionDecl *FD = getCurFunctionDecl()) +    Length = FD->getIdentifier()->getLength();    else      Length = getCurMethodDecl()->getSynthesizedMethodSize(); @@ -1438,7 +1438,7 @@ ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,                              DeclarationName()))      return true; -  bool isFileScope = !getCurFunctionDecl() && !getCurMethodDecl(); +  bool isFileScope = getCurFunctionOrMethodDecl() == 0;    if (isFileScope) { // 6.5.2.5p3      if (CheckForConstantInitializer(literalExpr, literalType))        return true; | 

