зеркало из https://github.com/microsoft/clang-1.git
Fix the type of predefined identifiers like __func__. Patch by
Eli Friedman! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45906 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
3c6f6a7a1b
Коммит
fa28b30d5a
|
@ -372,6 +372,8 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
|||
return LV_Valid;
|
||||
case ObjCIvarRefExprClass: // ObjC instance variables are lvalues.
|
||||
return LV_Valid;
|
||||
case PreDefinedExprClass:
|
||||
return LV_Valid;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -430,6 +432,8 @@ bool Expr::hasStaticStorage() const {
|
|||
}
|
||||
case ArraySubscriptExprClass:
|
||||
return cast<ArraySubscriptExpr>(this)->getBase()->hasStaticStorage();
|
||||
case PreDefinedExprClass:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -340,9 +340,6 @@ LValue CodeGenFunction::EmitPreDefinedLValue(const PreDefinedExpr *E) {
|
|||
C = new llvm::GlobalVariable(C->getType(), true,
|
||||
llvm::GlobalValue::InternalLinkage,
|
||||
C, GlobalVarName, CurFn->getParent());
|
||||
llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
|
||||
llvm::Constant *Zeros[] = { Zero, Zero };
|
||||
C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
|
||||
return LValue::MakeAddr(C);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,8 +128,13 @@ Sema::ExprResult Sema::ActOnPreDefinedExpr(SourceLocation Loc,
|
|||
break;
|
||||
}
|
||||
|
||||
// Pre-defined identifiers are always of type char *.
|
||||
return new PreDefinedExpr(Loc, Context.getPointerType(Context.CharTy), IT);
|
||||
// Pre-defined identifiers are of type char[x], where x is the length of the
|
||||
// string.
|
||||
llvm::APSInt Length(32);
|
||||
Length = CurFunctionDecl->getIdentifier()->getLength() + 1;
|
||||
QualType ResTy = Context.getConstantArrayType(Context.CharTy, Length,
|
||||
ArrayType::Normal, 0);
|
||||
return new PreDefinedExpr(Loc, ResTy, IT);
|
||||
}
|
||||
|
||||
Sema::ExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// RUN: clang -fsyntax-only %s
|
||||
|
||||
int abcdefghi12(void) {
|
||||
const char (*ss)[12] = &__func__;
|
||||
return sizeof(__func__);
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче