Skip to content

Commit cc509b9

Browse files
committed
Moved IsInsideFunction into Scope with a new name
1 parent 76a34f3 commit cc509b9

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

clang/include/clang/Sema/Scope.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,17 @@ class Scope {
427427
return false;
428428
}
429429

430+
/// isInObjcMethodScope - Return true if this scope is, or is contained, in an
431+
/// C function body.
432+
bool isInCFunctionScope() const {
433+
for (const Scope *S = this; S; S = S->getParent()) {
434+
if (S->isFunctionScope())
435+
return true;
436+
}
437+
438+
return false;
439+
}
440+
430441
/// isInObjcMethodScope - Return true if this scope is, or is contained in, an
431442
/// Objective-C method body. Note that this method is not constant time.
432443
bool isInObjcMethodScope() const {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7219,17 +7219,6 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
72197219
return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
72207220
}
72217221

7222-
static bool IsInsideFunction(Scope *S) {
7223-
while (S) {
7224-
if (S->isFunctionScope())
7225-
return true;
7226-
7227-
S = S->getParent();
7228-
}
7229-
7230-
return false;
7231-
}
7232-
72337222
ExprResult
72347223
Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
72357224
SourceLocation RParenLoc, Expr *LiteralExpr) {
@@ -7292,7 +7281,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
72927281
// void func(char *para[(int [1]){ 0 }[0]);
72937282
const Scope *S = getCurScope();
72947283
bool IsFileScope = !CurContext->isFunctionOrMethod() &&
7295-
!IsInsideFunction(getCurScope()) &&
7284+
!S->isInCFunctionScope() &&
72967285
(!S || !S->isFunctionPrototypeScope());
72977286

72987287
// In C, compound literals are l-values for some reason.

0 commit comments

Comments
 (0)