diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGCXXTemp.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 11 | ||||
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 62 | ||||
-rw-r--r-- | lib/CodeGen/CGDebugInfo.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 12 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/CGExprComplex.cpp | 117 | ||||
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 24 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 33 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 11 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 70 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 4 |
17 files changed, 252 insertions, 123 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index a919dfa..66b1f17 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -522,7 +522,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BIsqrtf: case Builtin::BIsqrtl: { // Rewrite sqrt to intrinsic if allowed. - if (!FD->hasAttr<ConstAttr>()) + if (!FD->hasAttr<ConstAttr>(getContext())) break; Value *Arg0 = EmitScalarExpr(E->getArg(0)); const llvm::Type *ArgType = Arg0->getType(); @@ -534,7 +534,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BIpowf: case Builtin::BIpowl: { // Rewrite sqrt to intrinsic if allowed. - if (!FD->hasAttr<ConstAttr>()) + if (!FD->hasAttr<ConstAttr>(getContext())) break; Value *Base = EmitScalarExpr(E->getArg(0)); Value *Exponent = EmitScalarExpr(E->getArg(1)); diff --git a/lib/CodeGen/CGCXXTemp.cpp b/lib/CodeGen/CGCXXTemp.cpp index 141726a..a6e6d11 100644 --- a/lib/CodeGen/CGCXXTemp.cpp +++ b/lib/CodeGen/CGCXXTemp.cpp @@ -85,6 +85,11 @@ RValue CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E, llvm::Value *AggLoc, bool isAggLocVolatile) { + // If we shouldn't destroy the temporaries, just emit the + // child expression. + if (!E->shouldDestroyTemporaries()) + return EmitAnyExpr(E->getSubExpr(), AggLoc, isAggLocVolatile); + // Keep track of the current cleanup stack depth. size_t CleanupStackDepth = CleanupEntries.size(); (void) CleanupStackDepth; diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 4037f32..ec6058a 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -377,13 +377,13 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, // FIXME: handle sseregparm someday... if (TargetDecl) { - if (TargetDecl->hasAttr<NoThrowAttr>()) + if (TargetDecl->hasAttr<NoThrowAttr>(getContext())) FuncAttrs |= llvm::Attribute::NoUnwind; - if (TargetDecl->hasAttr<NoReturnAttr>()) + if (TargetDecl->hasAttr<NoReturnAttr>(getContext())) FuncAttrs |= llvm::Attribute::NoReturn; - if (TargetDecl->hasAttr<ConstAttr>()) + if (TargetDecl->hasAttr<ConstAttr>(getContext())) FuncAttrs |= llvm::Attribute::ReadNone; - else if (TargetDecl->hasAttr<PureAttr>()) + else if (TargetDecl->hasAttr<PureAttr>(getContext())) FuncAttrs |= llvm::Attribute::ReadOnly; } @@ -432,7 +432,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, // register variable. signed RegParm = 0; if (TargetDecl) - if (const RegparmAttr *RegParmAttr = TargetDecl->getAttr<RegparmAttr>()) + if (const RegparmAttr *RegParmAttr + = TargetDecl->getAttr<RegparmAttr>(getContext())) RegParm = RegParmAttr->getNumParams(); unsigned PointerWidth = getContext().Target.getPointerWidth(0); diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 049e716..a2b8d13 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -50,6 +50,24 @@ void CGDebugInfo::setLocation(SourceLocation Loc) { /// getOrCreateCompileUnit - Get the compile unit from the cache or create a new /// one if necessary. This returns null for invalid source locations. llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { + + // Each input file is encoded as a separate compile unit in LLVM + // debugging information output. However, many target specific tool chains + // prefer to encode only one compile unit in an object file. In this + // situation, the LLVM code generator will include debugging information + // entities in the compile unit that is marked as main compile unit. The + // code generator accepts maximum one main compile unit per module. If a + // module does not contain any main compile unit then the code generator + // will emit multiple compile units in the output object file. Create main + // compile unit if there is not one available. + const LangOptions &LO = M->getLangOptions(); + if (isMainCompileUnitCreated == false) { + if (LO.getMainFileName()) { + createCompileUnit(LO.getMainFileName(), true /* isMain */); + isMainCompileUnitCreated = true; + } + } + // Get source file information. const char *FileName = "<unknown>"; SourceManager &SM = M->getContext().getSourceManager(); @@ -72,25 +90,26 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { AbsFileName = tmp; } - // See if thie compile unit is representing main source file. Each source - // file has corresponding compile unit. There is only one main source - // file at a time. - bool isMain = false; - const LangOptions &LO = M->getLangOptions(); - const char *MainFileName = LO.getMainFileName(); - if (isMainCompileUnitCreated == false) { - if (MainFileName) { - if (!strcmp(AbsFileName.getLast().c_str(), MainFileName)) - isMain = true; - } else { - if (Loc.isValid() && SM.isFromMainFile(Loc)) - isMain = true; - } - if (isMain) - isMainCompileUnitCreated = true; + // There is only one main source file at a time whose compile unit + // is already created. + Unit = createCompileUnit(FileName, false /* isMain */); + return Unit; +} + +/// createCompileUnit - Create a new unit for the given file. +llvm::DICompileUnit CGDebugInfo::createCompileUnit(const char *FileName, + bool isMain) { + + // Get absolute path name. + llvm::sys::Path AbsFileName(FileName); + if (!AbsFileName.isAbsolute()) { + llvm::sys::Path tmp = llvm::sys::Path::GetCurrentDirectory(); + tmp.appendComponent(FileName); + AbsFileName = tmp; } unsigned LangTag; + const LangOptions &LO = M->getLangOptions(); if (LO.CPlusPlus) { if (LO.ObjC1) LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus; @@ -114,12 +133,13 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { RuntimeVers = LO.ObjCNonFragileABI ? 2 : 1; // Create new compile unit. - return Unit = DebugFactory.CreateCompileUnit(LangTag, AbsFileName.getLast(), - AbsFileName.getDirname(), - Producer, isMain, isOptimized, - Flags, RuntimeVers); + return DebugFactory.CreateCompileUnit(LangTag, AbsFileName.getLast(), + AbsFileName.getDirname(), + Producer, isMain, isOptimized, + Flags, RuntimeVers); } + /// CreateType - Get the Basic type from the cache or create a new /// one if necessary. llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT, @@ -761,7 +781,7 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, case Type::QualifiedName: // Unsupported types return llvm::DIType(); - case Type::ObjCQualifiedId: // Encode id<p> in debug info just like id. + case Type::ObjCObjectPointer: // Encode id<p> in debug info just like id. return Slot = getOrCreateType(M->getContext().getObjCIdType(), Unit); case Type::ObjCQualifiedInterface: // Drop protocols from interface. diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index de65580..8f3368e 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -111,7 +111,9 @@ private: void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI, CGBuilderTy &Builder); - + /// createCompileUnit - Create a new unit for the given file. + llvm::DICompileUnit createCompileUnit(const char *FileName, bool isMain); + /// getOrCreateCompileUnit - Get the compile unit from the cache or create a /// new one if necessary. llvm::DICompileUnit getOrCreateCompileUnit(SourceLocation Loc); diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 29eaaad..4e603c3 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -60,7 +60,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) { /// EmitBlockVarDecl - This method handles emission of any variable declaration /// inside a function, including static vars etc. void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) { - if (D.hasAttr<AsmLabelAttr>()) + if (D.hasAttr<AsmLabelAttr>(getContext())) CGM.ErrorUnsupported(&D, "__asm__"); switch (D.getStorageClass()) { @@ -171,7 +171,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { } // FIXME: Merge attribute handling. - if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) { + if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>(getContext())) { SourceManager &SM = CGM.getContext().getSourceManager(); llvm::Constant *Ann = CGM.EmitAnnotateAttr(GV, AA, @@ -179,10 +179,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { CGM.AddAnnotation(Ann); } - if (const SectionAttr *SA = D.getAttr<SectionAttr>()) + if (const SectionAttr *SA = D.getAttr<SectionAttr>(getContext())) GV->setSection(SA->getName()); - if (D.hasAttr<UsedAttr>()) + if (D.hasAttr<UsedAttr>(getContext())) CGM.AddUsedGlobal(GV); // We may have to cast the constant because of the initializer @@ -244,7 +244,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty, /// These turn into simple stack objects, or GlobalValues depending on target. void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { QualType Ty = D.getType(); - bool isByRef = D.hasAttr<BlocksAttr>(); + bool isByRef = D.hasAttr<BlocksAttr>(getContext()); bool needsDispose = false; unsigned Align = 0; @@ -414,7 +414,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { } // Handle the cleanup attribute - if (const CleanupAttr *CA = D.getAttr<CleanupAttr>()) { + if (const CleanupAttr *CA = D.getAttr<CleanupAttr>(getContext())) { const FunctionDecl *FD = CA->getFunctionDecl(); llvm::Constant* F = CGM.GetAddrOfFunction(GlobalDecl(FD)); diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index eb0db61..51c5b3d 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -668,7 +668,8 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { if (VD && (VD->isBlockVarDecl() || isa<ParmVarDecl>(VD) || isa<ImplicitParamDecl>(VD))) { LValue LV; - bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>(); + bool NonGCable = VD->hasLocalStorage() && + !VD->hasAttr<BlocksAttr>(getContext()); if (VD->hasExternalStorage()) { llvm::Value *V = CGM.GetAddrOfGlobalVar(VD); if (VD->getType()->isReferenceType()) @@ -684,7 +685,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { // local static? if (!NonGCable) attr = getContext().getObjCGCAttrKind(E->getType()); - if (VD->hasAttr<BlocksAttr>()) { + if (VD->hasAttr<BlocksAttr>(getContext())) { bool needsCopyDispose = BlockRequiresCopying(VD->getType()); const llvm::Type *PtrStructTy = V->getType(); const llvm::Type *Ty = PtrStructTy; diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index e1332ff..3555c8c 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -365,23 +365,28 @@ ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) { ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, bool isInc, bool isPre) { LValue LV = CGF.EmitLValue(E->getSubExpr()); - ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), LV.isVolatileQualified()); + ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), + LV.isVolatileQualified()); llvm::Value *NextVal; if (isa<llvm::IntegerType>(InVal.first->getType())) { uint64_t AmountVal = isInc ? 1 : -1; NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal, true); + + // Add the inc/dec to the real part. + NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); + } else { QualType ElemTy = E->getType()->getAsComplexType()->getElementType(); llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1); if (!isInc) FVal.changeSign(); NextVal = llvm::ConstantFP::get(FVal); + + // Add the inc/dec to the real part. + NextVal = Builder.CreateFAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); } - // Add the inc/dec to the real part. - NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); - ComplexPairTy IncVal(NextVal, InVal.second); // Store the updated result through the lvalue. @@ -398,8 +403,15 @@ ComplexPairTy ComplexExprEmitter::VisitUnaryMinus(const UnaryOperator *E) { TestAndClearIgnoreRealAssign(); TestAndClearIgnoreImagAssign(); ComplexPairTy Op = Visit(E->getSubExpr()); - llvm::Value *ResR = Builder.CreateNeg(Op.first, "neg.r"); - llvm::Value *ResI = Builder.CreateNeg(Op.second, "neg.i"); + + llvm::Value *ResR, *ResI; + if (Op.first->getType()->isFloatingPoint()) { + ResR = Builder.CreateFNeg(Op.first, "neg.r"); + ResI = Builder.CreateFNeg(Op.second, "neg.i"); + } else { + ResR = Builder.CreateNeg(Op.first, "neg.r"); + ResI = Builder.CreateNeg(Op.second, "neg.i"); + } return ComplexPairTy(ResR, ResI); } @@ -410,31 +422,62 @@ ComplexPairTy ComplexExprEmitter::VisitUnaryNot(const UnaryOperator *E) { TestAndClearIgnoreImagAssign(); // ~(a+ib) = a + i*-b ComplexPairTy Op = Visit(E->getSubExpr()); - llvm::Value *ResI = Builder.CreateNeg(Op.second, "conj.i"); + llvm::Value *ResI; + if (Op.second->getType()->isFloatingPoint()) + ResI = Builder.CreateFNeg(Op.second, "conj.i"); + else + ResI = Builder.CreateNeg(Op.second, "conj.i"); + return ComplexPairTy(Op.first, ResI); } ComplexPairTy ComplexExprEmitter::EmitBinAdd(const BinOpInfo &Op) { - llvm::Value *ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first, "add.r"); - llvm::Value *ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second, "add.i"); + llvm::Value *ResR, *ResI; + + if (Op.LHS.first->getType()->isFloatingPoint()) { + ResR = Builder.CreateFAdd(Op.LHS.first, Op.RHS.first, "add.r"); + ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second, "add.i"); + } else { + ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first, "add.r"); + ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second, "add.i"); + } return ComplexPairTy(ResR, ResI); } ComplexPairTy ComplexExprEmitter::EmitBinSub(const BinOpInfo &Op) { - llvm::Value *ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first, "sub.r"); - llvm::Value *ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second, "sub.i"); + llvm::Value *ResR, *ResI; + if (Op.LHS.first->getType()->isFloatingPoint()) { + ResR = Builder.CreateFSub(Op.LHS.first, Op.RHS.first, "sub.r"); + ResI = Builder.CreateFSub(Op.LHS.second, Op.RHS.second, "sub.i"); + } else { + ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first, "sub.r"); + ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second, "sub.i"); + } return ComplexPairTy(ResR, ResI); } ComplexPairTy ComplexExprEmitter::EmitBinMul(const BinOpInfo &Op) { - llvm::Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first, "mul.rl"); - llvm::Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,"mul.rr"); - llvm::Value *ResR = Builder.CreateSub(ResRl, ResRr, "mul.r"); + using llvm::Value; + Value *ResR, *ResI; - llvm::Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first, "mul.il"); - llvm::Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second, "mul.ir"); - llvm::Value *ResI = Builder.CreateAdd(ResIl, ResIr, "mul.i"); + if (Op.LHS.first->getType()->isFloatingPoint()) { + Value *ResRl = Builder.CreateFMul(Op.LHS.first, Op.RHS.first, "mul.rl"); + Value *ResRr = Builder.CreateFMul(Op.LHS.second, Op.RHS.second,"mul.rr"); + ResR = Builder.CreateFSub(ResRl, ResRr, "mul.r"); + + Value *ResIl = Builder.CreateFMul(Op.LHS.second, Op.RHS.first, "mul.il"); + Value *ResIr = Builder.CreateFMul(Op.LHS.first, Op.RHS.second, "mul.ir"); + ResI = Builder.CreateFAdd(ResIl, ResIr, "mul.i"); + } else { + Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first, "mul.rl"); + Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,"mul.rr"); + ResR = Builder.CreateSub(ResRl, ResRr, "mul.r"); + + Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first, "mul.il"); + Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second, "mul.ir"); + ResI = Builder.CreateAdd(ResIl, ResIr, "mul.i"); + } return ComplexPairTy(ResR, ResI); } @@ -442,24 +485,38 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const BinOpInfo &Op) { llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second; llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second; - // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) - llvm::Value *Tmp1 = Builder.CreateMul(LHSr, RHSr, "tmp"); // a*c - llvm::Value *Tmp2 = Builder.CreateMul(LHSi, RHSi, "tmp"); // b*d - llvm::Value *Tmp3 = Builder.CreateAdd(Tmp1, Tmp2, "tmp"); // ac+bd - - llvm::Value *Tmp4 = Builder.CreateMul(RHSr, RHSr, "tmp"); // c*c - llvm::Value *Tmp5 = Builder.CreateMul(RHSi, RHSi, "tmp"); // d*d - llvm::Value *Tmp6 = Builder.CreateAdd(Tmp4, Tmp5, "tmp"); // cc+dd - - llvm::Value *Tmp7 = Builder.CreateMul(LHSi, RHSr, "tmp"); // b*c - llvm::Value *Tmp8 = Builder.CreateMul(LHSr, RHSi, "tmp"); // a*d - llvm::Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8, "tmp"); // bc-ad llvm::Value *DSTr, *DSTi; - if (Tmp3->getType()->isFloatingPoint()) { + if (Op.LHS.first->getType()->isFloatingPoint()) { + // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) + llvm::Value *Tmp1 = Builder.CreateFMul(LHSr, RHSr, "tmp"); // a*c + llvm::Value *Tmp2 = Builder.CreateFMul(LHSi, RHSi, "tmp"); // b*d + llvm::Value *Tmp3 = Builder.CreateFAdd(Tmp1, Tmp2, "tmp"); // ac+bd + + llvm::Value *Tmp4 = Builder.CreateFMul(RHSr, RHSr, "tmp"); // c*c + llvm::Value *Tmp5 = Builder.CreateFMul(RHSi, RHSi, "tmp"); // d*d + llvm::Value *Tmp6 = Builder.CreateFAdd(Tmp4, Tmp5, "tmp"); // cc+dd + + llvm::Value *Tmp7 = Builder.CreateFMul(LHSi, RHSr, "tmp"); // b*c + llvm::Value *Tmp8 = Builder.CreateFMul(LHSr, RHSi, "tmp"); // a*d + llvm::Value *Tmp9 = Builder.CreateFSub(Tmp7, Tmp8, "tmp"); // bc-ad + DSTr = Builder.CreateFDiv(Tmp3, Tmp6, "tmp"); DSTi = Builder.CreateFDiv(Tmp9, Tmp6, "tmp"); } else { + // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) + llvm::Value *Tmp1 = Builder.CreateMul(LHSr, RHSr, "tmp"); // a*c + llvm::Value *Tmp2 = Builder.CreateMul(LHSi, RHSi, "tmp"); // b*d + llvm::Value *Tmp3 = Builder.CreateAdd(Tmp1, Tmp2, "tmp"); // ac+bd + + llvm::Value *Tmp4 = Builder.CreateMul(RHSr, RHSr, "tmp"); // c*c + llvm::Value *Tmp5 = Builder.CreateMul(RHSi, RHSi, "tmp"); // d*d + llvm::Value *Tmp6 = Builder.CreateAdd(Tmp4, Tmp5, "tmp"); // cc+dd + + llvm::Value *Tmp7 = Builder.CreateMul(LHSi, RHSr, "tmp"); // b*c + llvm::Value *Tmp8 = Builder.CreateMul(LHSr, RHSi, "tmp"); // a*d + llvm::Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8, "tmp"); // bc-ad + if (Op.Ty->getAsComplexType()->getElementType()->isUnsignedIntegerType()) { DSTr = Builder.CreateUDiv(Tmp3, Tmp6, "tmp"); DSTi = Builder.CreateUDiv(Tmp9, Tmp6, "tmp"); diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 0e21a00..0b109f9 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -198,16 +198,13 @@ public: // Copy initializer elements. Skip padding fields. unsigned EltNo = 0; // Element no in ILE - int FieldNo = 0; // Field no in RecordDecl bool RewriteType = false; for (RecordDecl::field_iterator Field = RD->field_begin(CGM.getContext()), FieldEnd = RD->field_end(CGM.getContext()); EltNo < ILE->getNumInits() && Field != FieldEnd; ++Field) { - FieldNo++; - if (!Field->getIdentifier()) - continue; - if (Field->isBitField()) { + if (!Field->getIdentifier()) + continue; InsertBitfieldIntoStruct(Elts, *Field, ILE->getInit(EltNo)); } else { unsigned FieldNo = CGM.getTypes().getLLVMFieldNo(*Field); diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index ed18d32..2af0639 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -294,6 +294,8 @@ public: if (CGF.getContext().getLangOptions().OverflowChecking && Ops.Ty->isSignedIntegerType()) return EmitOverflowCheckedBinOp(Ops); + if (Ops.LHS->getType()->isFPOrFPVector()) + return Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul"); return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul"); } /// Create a binary op that checks for overflow. @@ -699,11 +701,12 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, // An interesting aspect of this is that increment is always true. // Decrement does not have this property. NextVal = llvm::ConstantInt::getTrue(); + } else if (isa<llvm::IntegerType>(InVal->getType())) { + NextVal = llvm::ConstantInt::get(InVal->getType(), AmountVal); + NextVal = Builder.CreateAdd(InVal, NextVal, isInc ? "inc" : "dec"); } else { // Add the inc/dec to the real part. - if (isa<llvm::IntegerType>(InVal->getType())) - NextVal = llvm::ConstantInt::get(InVal->getType(), AmountVal); - else if (InVal->getType() == llvm::Type::FloatTy) + if (InVal->getType() == llvm::Type::FloatTy) NextVal = llvm::ConstantFP::get(llvm::APFloat(static_cast<float>(AmountVal))); else if (InVal->getType() == llvm::Type::DoubleTy) @@ -716,7 +719,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, &ignored); NextVal = llvm::ConstantFP::get(F); } - NextVal = Builder.CreateAdd(InVal, NextVal, isInc ? "inc" : "dec"); + NextVal = Builder.CreateFAdd(InVal, NextVal, isInc ? "inc" : "dec"); } // Store the updated result through the lvalue. @@ -735,6 +738,8 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, Value *ScalarExprEmitter::VisitUnaryMinus(const UnaryOperator *E) { TestAndClearIgnoreResultAssign(); Value *Op = Visit(E->getSubExpr()); + if (Op->getType()->isFPOrFPVector()) + return Builder.CreateFNeg(Op, "neg"); return Builder.CreateNeg(Op, "neg"); } @@ -982,9 +987,13 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) { Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) { if (!Ops.Ty->isPointerType()) { - if (CGF.getContext().getLangOptions().OverflowChecking - && Ops.Ty->isSignedIntegerType()) + if (CGF.getContext().getLangOptions().OverflowChecking && + Ops.Ty->isSignedIntegerType()) return EmitOverflowCheckedBinOp(Ops); + + if (Ops.LHS->getType()->isFPOrFPVector()) + return Builder.CreateFAdd(Ops.LHS, Ops.RHS, "add"); + return Builder.CreateAdd(Ops.LHS, Ops.RHS, "add"); } @@ -1050,6 +1059,9 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) { if (CGF.getContext().getLangOptions().OverflowChecking && Ops.Ty->isSignedIntegerType()) return EmitOverflowCheckedBinOp(Ops); + + if (Ops.LHS->getType()->isFPOrFPVector()) + return Builder.CreateFSub(Ops.LHS, Ops.RHS, "sub"); return Builder.CreateSub(Ops.LHS, Ops.RHS, "sub"); } diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 51f9a76..e7cf8e6 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -126,7 +126,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD, /// its pointer, name, and types registered in the class struture. void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) { // Check if we should generate debug info for this method. - if (CGM.getDebugInfo() && !OMD->hasAttr<NodebugAttr>()) + if (CGM.getDebugInfo() && !OMD->hasAttr<NodebugAttr>(getContext())) DebugInfo = CGM.getDebugInfo(); StartObjCMethod(OMD, OMD->getClassInterface()); EmitStmt(OMD->getBody(getContext())); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index a70f718..912479f 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -104,6 +104,7 @@ private: std::vector<llvm::Constant*> &V, const std::string &Name=""); llvm::GlobalVariable *ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar); + void EmitClassRef(const std::string &className); public: CGObjCGNU(CodeGen::CodeGenModule &cgm); virtual llvm::Constant *GenerateConstantString(const ObjCStringLiteral *); @@ -168,15 +169,31 @@ public: } // end anonymous namespace +/// Emits a reference to a dummy variable which is emitted with each class. +/// This ensures that a linker error will be generated when trying to link +/// together modules where a referenced class is not defined. +void CGObjCGNU::EmitClassRef(const std::string &className){ + std::string symbolRef = "__objc_class_ref_" + className; + // Don't emit two copies of the same symbol + if (TheModule.getGlobalVariable(symbolRef)) return; + std::string symbolName = "__objc_class_name_" + className; + llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(symbolName); + if (!ClassSymbol) { + ClassSymbol = new llvm::GlobalVariable(LongTy, false, + llvm::GlobalValue::ExternalLinkage, 0, symbolName, &TheModule); + } + new llvm::GlobalVariable(ClassSymbol->getType(), true, + llvm::GlobalValue::CommonLinkage, ClassSymbol, symbolRef, &TheModule); +} static std::string SymbolNameForClass(const std::string &ClassName) { - return "___objc_class_name_" + ClassName; + return "_OBJC_CLASS_" + ClassName; } static std::string SymbolNameForMethod(const std::string &ClassName, const std::string &CategoryName, const std::string &MethodName, bool isClassMethod) { - return "._objc_method_" + ClassName +"("+CategoryName+")"+ + return "_OBJC_METHOD_" + ClassName + "("+CategoryName+")"+ (isClassMethod ? "+" : "-") + MethodName; } @@ -217,6 +234,7 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm) llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder, const ObjCInterfaceDecl *OID) { llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getNameAsString()); + EmitClassRef(OID->getNameAsString()); ClassName = Builder.CreateStructGEP(ClassName, 0); std::vector<const llvm::Type*> Params(1, PtrToInt8Ty); @@ -831,14 +849,21 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { const ObjCInterfaceDecl * SuperClassDecl = OID->getClassInterface()->getSuperClass(); std::string SuperClassName; - if (SuperClassDecl) + if (SuperClassDecl) { SuperClassName = SuperClassDecl->getNameAsString(); + EmitClassRef(SuperClassName); + } // Get the class name ObjCInterfaceDecl *ClassDecl = const_cast<ObjCInterfaceDecl *>(OID->getClassInterface()); std::string ClassName = ClassDecl->getNameAsString(); - + // Emit the symbol that is used to generate linker errors if this class is + // referenced in other modules but not declared. + new llvm::GlobalVariable(LongTy, false, llvm::GlobalValue::ExternalLinkage, + llvm::ConstantInt::get(LongTy, 0), "__objc_class_name_" + ClassName, + &TheModule); + // Get the size of instances. int instanceSize = Context.getASTObjCImplementationLayout(OID).getSize() / 8; diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index bd5b05a..6ffca81 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1356,11 +1356,12 @@ static llvm::Constant *getConstantGEP(llvm::Constant *C, /// hasObjCExceptionAttribute - Return true if this class or any super /// class has the __objc_exception__ attribute. -static bool hasObjCExceptionAttribute(const ObjCInterfaceDecl *OID) { - if (OID->hasAttr<ObjCExceptionAttr>()) +static bool hasObjCExceptionAttribute(ASTContext &Context, + const ObjCInterfaceDecl *OID) { + if (OID->hasAttr<ObjCExceptionAttr>(Context)) return true; if (const ObjCInterfaceDecl *Super = OID->getSuperClass()) - return hasObjCExceptionAttribute(Super); + return hasObjCExceptionAttribute(Context, Super); return false; } @@ -4402,7 +4403,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { if (classIsHidden) flags |= OBJC2_CLS_HIDDEN; - if (hasObjCExceptionAttribute(ID->getClassInterface())) + if (hasObjCExceptionAttribute(CGM.getContext(), ID->getClassInterface())) flags |= CLS_EXCEPTION; if (!ID->getClassInterface()->getSuperClass()) { @@ -5686,7 +5687,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, // If this type (or a super class) has the __objc_exception__ // attribute, emit an external reference. - if (hasObjCExceptionAttribute(ID)) + if (hasObjCExceptionAttribute(CGM.getContext(), ID)) return Entry = new llvm::GlobalVariable(ObjCTypes.EHTypeTy, false, llvm::GlobalValue::ExternalLinkage, diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 672f6da..f10a08f 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -199,7 +199,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, void CodeGenFunction::GenerateCode(const FunctionDecl *FD, llvm::Function *Fn) { // Check if we should generate debug info for this function. - if (CGM.getDebugInfo() && !FD->hasAttr<NodebugAttr>()) + if (CGM.getDebugInfo() && !FD->hasAttr<NodebugAttr>(getContext())) DebugInfo = CGM.getDebugInfo(); FunctionArgList Args; diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 82156e9..f926c05 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -102,7 +102,7 @@ CodeGenModule::getDeclVisibilityMode(const Decl *D) const { if (VD->getStorageClass() == VarDecl::PrivateExtern) return LangOptions::Hidden; - if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) { + if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>(getContext())) { switch (attr->getVisibility()) { default: assert(0 && "Unknown visibility!"); case VisibilityAttr::DefaultVisibility: @@ -241,10 +241,11 @@ void CodeGenModule::EmitAnnotations() { } static CodeGenModule::GVALinkage -GetLinkageForFunction(const FunctionDecl *FD, const LangOptions &Features) { +GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD, + const LangOptions &Features) { if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) { // C++ member functions defined inside the class are always inline. - if (MD->isInline() || !MD->isOutOfLineDefinition()) + if (MD->isInline() || !MD->isOutOfLine()) return CodeGenModule::GVA_CXXInline; return CodeGenModule::GVA_StrongExternal; @@ -265,11 +266,11 @@ GetLinkageForFunction(const FunctionDecl *FD, const LangOptions &Features) { return CodeGenModule::GVA_C99Inline; // Normal inline is a strong symbol. return CodeGenModule::GVA_StrongExternal; - } else if (FD->hasActiveGNUInlineAttribute()) { + } else if (FD->hasActiveGNUInlineAttribute(Context)) { // GCC in C99 mode seems to use a different decision-making // process for extern inline, which factors in previous // declarations. - if (FD->isExternGNUInline()) + if (FD->isExternGNUInline(Context)) return CodeGenModule::GVA_C99Inline; // Normal inline is a strong symbol. return CodeGenModule::GVA_StrongExternal; @@ -293,13 +294,13 @@ GetLinkageForFunction(const FunctionDecl *FD, const LangOptions &Features) { /// variables (these details are set in EmitGlobalVarDefinition for variables). void CodeGenModule::SetFunctionDefinitionAttributes(const FunctionDecl *D, llvm::GlobalValue *GV) { - GVALinkage Linkage = GetLinkageForFunction(D, Features); + GVALinkage Linkage = GetLinkageForFunction(getContext(), D, Features); if (Linkage == GVA_Internal) { GV->setLinkage(llvm::Function::InternalLinkage); - } else if (D->hasAttr<DLLExportAttr>()) { + } else if (D->hasAttr<DLLExportAttr>(getContext())) { GV->setLinkage(llvm::Function::DLLExportLinkage); - } else if (D->hasAttr<WeakAttr>()) { + } else if (D->hasAttr<WeakAttr>(getContext())) { GV->setLinkage(llvm::Function::WeakAnyLinkage); } else if (Linkage == GVA_C99Inline) { // In C99 mode, 'inline' functions are guaranteed to have a strong @@ -332,10 +333,10 @@ void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D, AttributeList.size())); // Set the appropriate calling convention for the Function. - if (D->hasAttr<FastCallAttr>()) + if (D->hasAttr<FastCallAttr>(getContext())) F->setCallingConv(llvm::CallingConv::X86_FastCall); - if (D->hasAttr<StdCallAttr>()) + if (D->hasAttr<StdCallAttr>(getContext())) F->setCallingConv(llvm::CallingConv::X86_StdCall); } @@ -344,10 +345,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (!Features.Exceptions && !Features.ObjCNonFragileABI) F->addFnAttr(llvm::Attribute::NoUnwind); - if (D->hasAttr<AlwaysInlineAttr>()) + if (D->hasAttr<AlwaysInlineAttr>(getContext())) F->addFnAttr(llvm::Attribute::AlwaysInline); - if (D->hasAttr<NoinlineAttr>()) + if (D->hasAttr<NoinlineAttr>(getContext())) F->addFnAttr(llvm::Attribute::NoInline); } @@ -355,10 +356,10 @@ void CodeGenModule::SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV) { setGlobalVisibility(GV, D); - if (D->hasAttr<UsedAttr>()) + if (D->hasAttr<UsedAttr>(getContext())) AddUsedGlobal(GV); - if (const SectionAttr *SA = D->getAttr<SectionAttr>()) + if (const SectionAttr *SA = D->getAttr<SectionAttr>(getContext())) GV->setSection(SA->getName()); } @@ -382,9 +383,10 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD, // Only a few attributes are set on declarations; these may later be // overridden by a definition. - if (FD->hasAttr<DLLImportAttr>()) { + if (FD->hasAttr<DLLImportAttr>(getContext())) { F->setLinkage(llvm::Function::DLLImportLinkage); - } else if (FD->hasAttr<WeakAttr>() || FD->hasAttr<WeakImportAttr>()) { + } else if (FD->hasAttr<WeakAttr>(getContext()) || + FD->hasAttr<WeakImportAttr>(getContext())) { // "extern_weak" is overloaded in LLVM; we probably should have // separate linkage types for this. F->setLinkage(llvm::Function::ExternalWeakLinkage); @@ -392,7 +394,7 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD, F->setLinkage(llvm::Function::ExternalLinkage); } - if (const SectionAttr *SA = FD->getAttr<SectionAttr>()) + if (const SectionAttr *SA = FD->getAttr<SectionAttr>(getContext())) F->setSection(SA->getName()); } @@ -499,15 +501,16 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV, bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) { // Never defer when EmitAllDecls is specified or the decl has // attribute used. - if (Features.EmitAllDecls || Global->hasAttr<UsedAttr>()) + if (Features.EmitAllDecls || Global->hasAttr<UsedAttr>(getContext())) return false; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Global)) { // Constructors and destructors should never be deferred. - if (FD->hasAttr<ConstructorAttr>() || FD->hasAttr<DestructorAttr>()) + if (FD->hasAttr<ConstructorAttr>(getContext()) || + FD->hasAttr<DestructorAttr>(getContext())) return false; - GVALinkage Linkage = GetLinkageForFunction(FD, Features); + GVALinkage Linkage = GetLinkageForFunction(getContext(), FD, Features); // static, static inline, always_inline, and extern inline functions can // always be deferred. Normal inline functions can be deferred in C99/C++. @@ -528,7 +531,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { // If this is an alias definition (which otherwise looks like a declaration) // emit it now. - if (Global->hasAttr<AliasAttr>()) + if (Global->hasAttr<AliasAttr>(getContext())) return EmitAliasDefinition(Global); // Ignore declarations, they will be emitted on their first use. @@ -717,7 +720,8 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName, if (D->getStorageClass() == VarDecl::PrivateExtern) GV->setVisibility(llvm::GlobalValue::HiddenVisibility); - if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakImportAttr>()) + if (D->hasAttr<WeakAttr>(getContext()) || + D->hasAttr<WeakImportAttr>(getContext())) GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); GV->setThreadLocal(D->isThreadSpecified()); @@ -837,7 +841,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { cast<llvm::GlobalValue>(Entry)->eraseFromParent(); } - if (const AnnotateAttr *AA = D->getAttr<AnnotateAttr>()) { + if (const AnnotateAttr *AA = D->getAttr<AnnotateAttr>(getContext())) { SourceManager &SM = Context.getSourceManager(); AddAnnotation(EmitAnnotateAttr(GV, AA, SM.getInstantiationLineNumber(D->getLocation()))); @@ -850,11 +854,11 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { // Set the llvm linkage type as appropriate. if (D->getStorageClass() == VarDecl::Static) GV->setLinkage(llvm::Function::InternalLinkage); - else if (D->hasAttr<DLLImportAttr>()) + else if (D->hasAttr<DLLImportAttr>(getContext())) GV->setLinkage(llvm::Function::DLLImportLinkage); - else if (D->hasAttr<DLLExportAttr>()) + else if (D->hasAttr<DLLExportAttr>(getContext())) GV->setLinkage(llvm::Function::DLLExportLinkage); - else if (D->hasAttr<WeakAttr>()) + else if (D->hasAttr<WeakAttr>(getContext())) GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage); else if (!CompileOpts.NoCommon && (!D->hasExternalStorage() && !D->getInit())) @@ -1017,14 +1021,14 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { SetFunctionDefinitionAttributes(D, Fn); SetLLVMFunctionAttributesForDefinition(D, Fn); - if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>()) + if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>(getContext())) AddGlobalCtor(Fn, CA->getPriority()); - if (const DestructorAttr *DA = D->getAttr<DestructorAttr>()) + if (const DestructorAttr *DA = D->getAttr<DestructorAttr>(getContext())) AddGlobalDtor(Fn, DA->getPriority()); } void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { - const AliasAttr *AA = D->getAttr<AliasAttr>(); + const AliasAttr *AA = D->getAttr<AliasAttr>(getContext()); assert(AA && "Not an alias?"); const llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType()); @@ -1080,7 +1084,7 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { // Set attributes which are particular to an alias; this is a // specialization of the attributes which may be set on a global // variable/function. - if (D->hasAttr<DLLExportAttr>()) { + if (D->hasAttr<DLLExportAttr>(getContext())) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { // The dllexport attribute is ignored for undefined symbols. if (FD->getBody(getContext())) @@ -1088,7 +1092,8 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) { } else { GA->setLinkage(llvm::Function::DLLExportLinkage); } - } else if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakImportAttr>()) { + } else if (D->hasAttr<WeakAttr>(getContext()) || + D->hasAttr<WeakImportAttr>(getContext())) { GA->setLinkage(llvm::Function::WeakAnyLinkage); } @@ -1476,6 +1481,9 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { case Decl::Namespace: EmitNamespace(cast<NamespaceDecl>(D)); break; + // No code generation needed. + case Decl::Using: + break; case Decl::CXXConstructor: EmitCXXConstructors(cast<CXXConstructorDecl>(D)); break; diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index af791f6..f31c610 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -353,7 +353,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { return T; } - case Type::ObjCQualifiedId: + case Type::ObjCObjectPointer: // Protocols don't influence the LLVM type. return ConvertTypeRecursive(Context.getObjCIdType()); diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 14392ab..24e441a 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -87,7 +87,7 @@ static bool isInCLinkageSpecification(const Decl *D) { bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) { // Clang's "overloadable" attribute extension to C/C++ implies // name mangling (always). - if (!FD->hasAttr<OverloadableAttr>()) { + if (!FD->hasAttr<OverloadableAttr>(Context)) { // C functions are not mangled, and "main" is never mangled. if (!Context.getLangOptions().CPlusPlus || FD->isMain()) return false; @@ -111,7 +111,7 @@ bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) { bool CXXNameMangler::mangle(const NamedDecl *D) { // Any decl can be declared with __asm("foo") on it, and this takes // precedence over all other naming in the .o file. - if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) { + if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>(Context)) { // If we have an asm name, then we use it as the mangling. Out << '\01'; // LLVM IR Marker for __asm("foo") Out << ALA->getLabel(); |