зеркало из https://github.com/microsoft/clang-1.git
Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f40fd6bbb2
Коммит
e1f549028b
|
@ -46,7 +46,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
|
|||
case Decl::Field:
|
||||
case Decl::IndirectField:
|
||||
case Decl::ObjCIvar:
|
||||
case Decl::ObjCAtDefsField:
|
||||
case Decl::ObjCAtDefsField:
|
||||
case Decl::ParmVar:
|
||||
case Decl::ImplicitParam:
|
||||
case Decl::ClassTemplate:
|
||||
|
@ -113,7 +113,7 @@ void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
|
|||
case SC_Register:
|
||||
return EmitAutoVarDecl(D);
|
||||
case SC_Static: {
|
||||
llvm::GlobalValue::LinkageTypes Linkage =
|
||||
llvm::GlobalValue::LinkageTypes Linkage =
|
||||
llvm::GlobalValue::InternalLinkage;
|
||||
|
||||
// If the function definition has some sort of weak linkage, its
|
||||
|
@ -124,7 +124,7 @@ void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
|
|||
if (getContext().getLangOptions().CPlusPlus)
|
||||
if (llvm::GlobalValue::isWeakForLinker(CurFn->getLinkage()))
|
||||
Linkage = CurFn->getLinkage();
|
||||
|
||||
|
||||
return EmitStaticVarDecl(D, Linkage);
|
||||
}
|
||||
case SC_Extern:
|
||||
|
@ -143,7 +143,7 @@ static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
|
|||
StringRef Name = CGM.getMangledName(&D);
|
||||
return Name.str();
|
||||
}
|
||||
|
||||
|
||||
std::string ContextName;
|
||||
if (!CGF.CurFuncDecl) {
|
||||
// Better be in a block declared in global scope.
|
||||
|
@ -163,7 +163,7 @@ static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
|
|||
ContextName = CGF.CurFn->getName();
|
||||
else
|
||||
assert(0 && "Unknown context for static var decl");
|
||||
|
||||
|
||||
return ContextName + Separator + D.getNameAsString();
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
|
|||
if (!getContext().getLangOptions().CPlusPlus)
|
||||
CGM.ErrorUnsupported(D.getInit(), "constant l-value expression");
|
||||
else if (Builder.GetInsertBlock()) {
|
||||
// Since we have a static initializer, this global variable can't
|
||||
// Since we have a static initializer, this global variable can't
|
||||
// be constant.
|
||||
GV->setConstant(false);
|
||||
|
||||
|
@ -219,7 +219,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
|
|||
// in the LLVM type system.)
|
||||
if (GV->getType()->getElementType() != Init->getType()) {
|
||||
llvm::GlobalVariable *OldGV = GV;
|
||||
|
||||
|
||||
GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
|
||||
OldGV->isConstant(),
|
||||
OldGV->getLinkage(), Init, "",
|
||||
|
@ -227,19 +227,19 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
|
|||
D.isThreadSpecified(),
|
||||
CGM.getContext().getTargetAddressSpace(D.getType()));
|
||||
GV->setVisibility(OldGV->getVisibility());
|
||||
|
||||
|
||||
// Steal the name of the old global
|
||||
GV->takeName(OldGV);
|
||||
|
||||
|
||||
// Replace all uses of the old global with the new global
|
||||
llvm::Constant *NewPtrForOldDecl =
|
||||
llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
|
||||
OldGV->replaceAllUsesWith(NewPtrForOldDecl);
|
||||
|
||||
|
||||
// Erase the old global, since it is no longer used.
|
||||
OldGV->eraseFromParent();
|
||||
}
|
||||
|
||||
|
||||
GV->setInitializer(Init);
|
||||
return GV;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
|
|||
// Make sure to evaluate VLA bounds now so that we have them for later.
|
||||
if (D.getType()->isVariablyModifiedType())
|
||||
EmitVariablyModifiedType(D.getType());
|
||||
|
||||
|
||||
// Local static block variables must be treated as globals as they may be
|
||||
// referenced in their RHS initializer block-literal expresion.
|
||||
CGM.setStaticLocalDeclAddress(&D, GV);
|
||||
|
@ -348,7 +348,7 @@ namespace {
|
|||
CGF.Builder.CreateCondBr(DidNRVO, SkipDtorBB, RunDtorBB);
|
||||
CGF.EmitBlock(RunDtorBB);
|
||||
}
|
||||
|
||||
|
||||
CGF.EmitCXXDestructorCall(Dtor, Dtor_Complete,
|
||||
/*ForVirtualBase=*/false, Loc);
|
||||
|
||||
|
@ -384,7 +384,7 @@ namespace {
|
|||
llvm::Constant *CleanupFn;
|
||||
const CGFunctionInfo &FnInfo;
|
||||
const VarDecl &Var;
|
||||
|
||||
|
||||
CallCleanupFunction(llvm::Constant *CleanupFn, const CGFunctionInfo *Info,
|
||||
const VarDecl *Var)
|
||||
: CleanupFn(CleanupFn), FnInfo(*Info), Var(*Var) {}
|
||||
|
@ -441,7 +441,7 @@ static void EmitAutoVarWithLifetime(CodeGenFunction &CGF, const VarDecl &var,
|
|||
case Qualifiers::OCL_Autoreleasing:
|
||||
// nothing to do
|
||||
break;
|
||||
|
||||
|
||||
case Qualifiers::OCL_Weak:
|
||||
// __weak objects always get EH cleanups; otherwise, exceptions
|
||||
// could cause really nasty crashes instead of mere leaks.
|
||||
|
@ -524,7 +524,7 @@ void CodeGenFunction::EmitScalarInit(const Expr *init,
|
|||
ty = cast<llvm::PointerType>(ty->getElementType());
|
||||
|
||||
llvm::Value *zero = llvm::ConstantPointerNull::get(ty);
|
||||
|
||||
|
||||
// If __weak, we want to use a barrier under certain conditions.
|
||||
if (lifetime == Qualifiers::OCL_Weak)
|
||||
EmitARCInitWeak(tempLV.getAddress(), zero);
|
||||
|
@ -613,7 +613,7 @@ void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) {
|
|||
break;
|
||||
}
|
||||
|
||||
EmitStoreOfScalar(init, lvalue);
|
||||
EmitStoreOfScalar(init, lvalue);
|
||||
}
|
||||
|
||||
/// canEmitInitWithFewStoresAfterMemset - Decide whether we can emit the
|
||||
|
@ -640,7 +640,7 @@ static bool canEmitInitWithFewStoresAfterMemset(llvm::Constant *Init,
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Anything else is hard and scary.
|
||||
return false;
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ static void emitStoresForInitAfterMemset(llvm::Constant *Init, llvm::Value *Loc,
|
|||
isa<llvm::ConstantPointerNull>(Init) ||
|
||||
isa<llvm::UndefValue>(Init))
|
||||
return;
|
||||
|
||||
|
||||
if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
|
||||
isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
|
||||
isa<llvm::ConstantExpr>(Init)) {
|
||||
|
@ -663,14 +663,14 @@ static void emitStoresForInitAfterMemset(llvm::Constant *Init, llvm::Value *Loc,
|
|||
Builder.CreateStore(Init, Loc, isVolatile);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
assert((isa<llvm::ConstantStruct>(Init) || isa<llvm::ConstantArray>(Init)) &&
|
||||
"Unknown value type!");
|
||||
|
||||
|
||||
for (unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
|
||||
llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
|
||||
if (Elt->isNullValue()) continue;
|
||||
|
||||
|
||||
// Otherwise, get a pointer to the element and emit it.
|
||||
emitStoresForInitAfterMemset(Elt, Builder.CreateConstGEP2_32(Loc, 0, i),
|
||||
isVolatile, Builder);
|
||||
|
@ -694,8 +694,8 @@ static bool shouldUseMemSetPlusStoresToInitialize(llvm::Constant *Init,
|
|||
// plopping in more stores.
|
||||
unsigned StoreBudget = 6;
|
||||
uint64_t SizeLimit = 32;
|
||||
|
||||
return GlobalSize > SizeLimit &&
|
||||
|
||||
return GlobalSize > SizeLimit &&
|
||||
canEmitInitWithFewStoresAfterMemset(Init, StoreBudget);
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
|
|||
llvm::Value *DeclPtr;
|
||||
if (Ty->isConstantSizeType()) {
|
||||
if (!Target.useGlobalsForAutomaticVariables()) {
|
||||
bool NRVO = getContext().getLangOptions().ElideConstructors &&
|
||||
bool NRVO = getContext().getLangOptions().ElideConstructors &&
|
||||
D.isNRVOVariable();
|
||||
|
||||
// If this value is a POD array or struct with a statically
|
||||
|
@ -740,7 +740,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
|
|||
// arrays as long as the initialization is trivial (e.g. if they
|
||||
// have a non-trivial destructor, but not a non-trivial constructor).
|
||||
if (D.getInit() &&
|
||||
(Ty->isArrayType() || Ty->isRecordType()) &&
|
||||
(Ty->isArrayType() || Ty->isRecordType()) &&
|
||||
(Ty.isPODType(getContext()) ||
|
||||
getContext().getBaseElementType(Ty)->isObjCObjectPointerType()) &&
|
||||
D.getInit()->isConstantInitializer(getContext(), false)) {
|
||||
|
@ -759,27 +759,27 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
|
|||
// Otherwise, tell the initialization code that we're in this case.
|
||||
emission.IsConstantAggregate = true;
|
||||
}
|
||||
|
||||
|
||||
// A normal fixed sized variable becomes an alloca in the entry block,
|
||||
// unless it's an NRVO variable.
|
||||
llvm::Type *LTy = ConvertTypeForMem(Ty);
|
||||
|
||||
|
||||
if (NRVO) {
|
||||
// The named return value optimization: allocate this variable in the
|
||||
// return slot, so that we can elide the copy when returning this
|
||||
// variable (C++0x [class.copy]p34).
|
||||
DeclPtr = ReturnValue;
|
||||
|
||||
|
||||
if (const RecordType *RecordTy = Ty->getAs<RecordType>()) {
|
||||
if (!cast<CXXRecordDecl>(RecordTy->getDecl())->hasTrivialDestructor()) {
|
||||
// Create a flag that is used to indicate when the NRVO was applied
|
||||
// to this variable. Set it to zero to indicate that NRVO was not
|
||||
// to this variable. Set it to zero to indicate that NRVO was not
|
||||
// applied.
|
||||
llvm::Value *Zero = Builder.getFalse();
|
||||
llvm::Value *NRVOFlag = CreateTempAlloca(Zero->getType(), "nrvo");
|
||||
EnsureInsertPoint();
|
||||
Builder.CreateStore(Zero, NRVOFlag);
|
||||
|
||||
|
||||
// Record the NRVO flag for this variable.
|
||||
NRVOFlags[&D] = NRVOFlag;
|
||||
emission.NRVOFlag = NRVOFlag;
|
||||
|
@ -788,13 +788,13 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
|
|||
} else {
|
||||
if (isByRef)
|
||||
LTy = BuildByRefType(&D);
|
||||
|
||||
|
||||
llvm::AllocaInst *Alloc = CreateTempAlloca(LTy);
|
||||
Alloc->setName(D.getNameAsString());
|
||||
|
||||
CharUnits allocaAlignment = alignment;
|
||||
if (isByRef)
|
||||
allocaAlignment = std::max(allocaAlignment,
|
||||
allocaAlignment = std::max(allocaAlignment,
|
||||
getContext().toCharUnitsFromBits(Target.getPointerAlign(0)));
|
||||
Alloc->setAlignment(allocaAlignment.getQuantity());
|
||||
DeclPtr = Alloc;
|
||||
|
@ -884,7 +884,7 @@ static bool isCapturedBy(const VarDecl &var, const Expr *e) {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (Stmt::const_child_range children = e->children(); children; ++children)
|
||||
if (isCapturedBy(var, cast<Expr>(*children)))
|
||||
return true;
|
||||
|
@ -897,14 +897,14 @@ static bool isCapturedBy(const VarDecl &var, const Expr *e) {
|
|||
static bool isTrivialInitializer(const Expr *Init) {
|
||||
if (!Init)
|
||||
return true;
|
||||
|
||||
|
||||
if (const CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init))
|
||||
if (CXXConstructorDecl *Constructor = Construct->getConstructor())
|
||||
if (Constructor->isTrivial() &&
|
||||
Constructor->isDefaultConstructor() &&
|
||||
!Construct->requiresZeroInitialization())
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
||||
|
@ -932,7 +932,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
|||
|
||||
if (isTrivialInitializer(Init))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
CharUnits alignment = emission.Alignment;
|
||||
|
||||
|
@ -960,7 +960,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
|||
assert(constant != 0 && "Wasn't a simple constant init?");
|
||||
|
||||
llvm::Value *SizeVal =
|
||||
llvm::ConstantInt::get(IntPtrTy,
|
||||
llvm::ConstantInt::get(IntPtrTy,
|
||||
getContext().getTypeSizeInChars(type).getQuantity());
|
||||
|
||||
llvm::Type *BP = Int8PtrTy;
|
||||
|
@ -969,7 +969,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
|||
|
||||
// If the initializer is all or mostly zeros, codegen with memset then do
|
||||
// a few stores afterward.
|
||||
if (shouldUseMemSetPlusStoresToInitialize(constant,
|
||||
if (shouldUseMemSetPlusStoresToInitialize(constant,
|
||||
CGM.getTargetData().getTypeAllocSize(constant->getType()))) {
|
||||
Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, 0), SizeVal,
|
||||
alignment.getQuantity(), isVolatile);
|
||||
|
@ -978,7 +978,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
|||
emitStoresForInitAfterMemset(constant, Loc, isVolatile, Builder);
|
||||
}
|
||||
} else {
|
||||
// Otherwise, create a temporary global with the initializer then
|
||||
// Otherwise, create a temporary global with the initializer then
|
||||
// memcpy from the global to the alloca.
|
||||
std::string Name = GetStaticDeclName(*this, D, ".");
|
||||
llvm::GlobalVariable *GV =
|
||||
|
@ -987,7 +987,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
|||
constant, Name, 0, false, 0);
|
||||
GV->setAlignment(alignment.getQuantity());
|
||||
GV->setUnnamedAddr(true);
|
||||
|
||||
|
||||
llvm::Value *SrcPtr = GV;
|
||||
if (SrcPtr->getType() != BP)
|
||||
SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
|
||||
|
@ -1017,7 +1017,7 @@ void CodeGenFunction::EmitExprAsInit(const Expr *init,
|
|||
|
||||
if (type->isReferenceType()) {
|
||||
RValue rvalue = EmitReferenceBindingToExpr(init, D);
|
||||
if (capturedByInit)
|
||||
if (capturedByInit)
|
||||
drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));
|
||||
EmitStoreThroughLValue(rvalue, lvalue);
|
||||
} else if (!hasAggregateLLVMType(type)) {
|
||||
|
@ -1068,7 +1068,7 @@ void CodeGenFunction::emitAutoVarTypeCleanup(
|
|||
case QualType::DK_objc_strong_lifetime:
|
||||
// Suppress cleanups for pseudo-strong variables.
|
||||
if (var->isARCPseudoStrong()) return;
|
||||
|
||||
|
||||
// Otherwise, consider whether to use an EH cleanup or not.
|
||||
cleanupKind = getARCCleanupKind();
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ namespace {
|
|||
/// pushIrregularPartialArrayCleanup - Push an EH cleanup to destroy
|
||||
/// already-constructed elements of the given array. The cleanup
|
||||
/// may be popped with DeactivateCleanupBlock or PopCleanupBlock.
|
||||
///
|
||||
///
|
||||
/// \param elementType - the immediate element type of the array;
|
||||
/// possibly still an array type
|
||||
/// \param array - a value of type elementType*
|
||||
|
@ -1357,7 +1357,7 @@ void CodeGenFunction::pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin,
|
|||
/// pushRegularPartialArrayCleanup - Push an EH cleanup to destroy
|
||||
/// already-constructed elements of the given array. The cleanup
|
||||
/// may be popped with DeactivateCleanupBlock or PopCleanupBlock.
|
||||
///
|
||||
///
|
||||
/// \param elementType - the immediate element type of the array;
|
||||
/// possibly still an array type
|
||||
/// \param array - a value of type elementType*
|
||||
|
|
Загрузка…
Ссылка в новой задаче