Index: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h =================================================================== --- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h +++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h @@ -58,18 +58,15 @@ llvm::BumpPtrAllocator *Allocator; }; - } // end namespace til } // end namespace threadSafety } // end namespace clang - inline void *operator new(size_t Sz, clang::threadSafety::til::MemRegionRef &R) { return R.allocate(Sz); } - namespace clang { namespace threadSafety { @@ -80,7 +77,6 @@ namespace til { - // A simple fixed size array class that does not manage its own memory, // suitable for use with bump pointer allocation. template class SimpleArray { @@ -117,7 +113,6 @@ Data = A.allocateT(Ncp); Capacity = Ncp; memcpy(Data, Odata, sizeof(T) * Size); - return; } // Reserve space for at least N more items. @@ -221,10 +216,8 @@ size_t Capacity; }; - } // end namespace til - // A copy on write vector. // The vector can be in one of three states: // * invalid -- no operations are permitted. @@ -346,13 +339,11 @@ VectorData *Data; }; - inline std::ostream& operator<<(std::ostream& ss, const StringRef str) { return ss.write(str.data(), str.size()); } - } // end namespace threadSafety } // end namespace clang -#endif // LLVM_CLANG_THREAD_SAFETY_UTIL_H +#endif // LLVM_CLANG_THREAD_SAFETY_UTIL_H Index: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp =================================================================== --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp @@ -177,7 +177,7 @@ } }; -} +} // end anonymous namespace ObjCMigrateAction::ObjCMigrateAction( std::unique_ptr WrappedAction, @@ -307,7 +307,6 @@ } return true; } - class ObjCMigrator : public RecursiveASTVisitor { ObjCMigrateASTConsumer &Consumer; @@ -370,7 +369,7 @@ return true; } }; -} +} // end anonymous namespace void ObjCMigrateASTConsumer::migrateDecl(Decl *D) { if (!D) @@ -1106,7 +1105,6 @@ versionsMatch(Deprecated1, Deprecated2) && versionsMatch(Obsoleted1, Obsoleted2) && IsUnavailable1 == IsUnavailable2); - } static bool MatchTwoAttributeLists(const AttrVec &Attrs1, const AttrVec &Attrs2, @@ -1511,7 +1509,6 @@ } } - ObjCMigrateASTConsumer::CF_BRIDGING_KIND ObjCMigrateASTConsumer::migrateAddFunctionAnnotation( ASTContext &Ctx, @@ -1685,7 +1682,6 @@ return; } } - return; } namespace { @@ -1702,7 +1698,7 @@ return true; } }; -} // anonymous namespace +} // end anonymous namespace static bool hasSuperInitCall(const ObjCMethodDecl *MD) { return !SuperInitChecker().TraverseStmt(MD->getBody()); @@ -1843,7 +1839,7 @@ } }; -} +} // end anonymous namespace void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { @@ -2044,7 +2040,7 @@ EditEntry() : File(), Offset(), RemoveLen() {} }; -} +} // end anonymous namespace namespace llvm { template<> struct DenseMapInfo { @@ -2073,7 +2069,7 @@ LHS.Text == RHS.Text; } }; -} +} // end namespace llvm namespace { class RemapFileParser { @@ -2155,7 +2151,7 @@ Entries.push_back(Entry); } }; -} +} // end anonymous namespace static bool reportDiag(const Twine &Err, DiagnosticsEngine &Diag) { Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")) Index: cfe/trunk/lib/AST/ASTDiagnostic.cpp =================================================================== --- cfe/trunk/lib/AST/ASTDiagnostic.cpp +++ cfe/trunk/lib/AST/ASTDiagnostic.cpp @@ -10,6 +10,7 @@ // This file implements a diagnostic formatting hook for AST elements. // //===----------------------------------------------------------------------===// + #include "clang/AST/ASTDiagnostic.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTLambda.h" @@ -443,7 +444,6 @@ NeedQuotes = false; break; } - } if (NeedQuotes) { @@ -1628,7 +1628,6 @@ Unbold(); OS << "]"; } - return; } /// PrintExpr - Prints out the expr template arguments, highlighting argument @@ -1840,7 +1839,6 @@ Unbold(); OS << ']'; } - } /// PrintValueDeclAndInteger - Uses the print functions for ValueDecl and @@ -2022,7 +2020,7 @@ return true; } }; // end class TemplateDiff -} // end namespace +} // end anonymous namespace /// FormatTemplateTypeDiff - A helper static function to start the template /// diff and return the properly formatted string. Returns true if the diff Index: cfe/trunk/lib/AST/CommentLexer.cpp =================================================================== --- cfe/trunk/lib/AST/CommentLexer.cpp +++ cfe/trunk/lib/AST/CommentLexer.cpp @@ -1,3 +1,12 @@ +//===--- CommentLexer.cpp -------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #include "clang/AST/CommentLexer.h" #include "clang/AST/CommentCommandTraits.h" #include "clang/AST/CommentDiagnostic.h" @@ -44,7 +53,7 @@ #include "clang/AST/CommentHTMLTags.inc" #include "clang/AST/CommentHTMLNamedCharacterReferences.inc" -} // unnamed namespace +} // end anonymous namespace StringRef Lexer::resolveHTMLNamedCharacterReference(StringRef Name) const { // Fast path, first check a few most widely used named character references. @@ -266,7 +275,7 @@ llvm_unreachable("buffer end hit before '*/' was seen"); } -} // unnamed namespace +} // end anonymous namespace void Lexer::formTokenWithChars(Token &Result, const char *TokEnd, tok::TokenKind Kind) { @@ -411,7 +420,6 @@ setupAndLexHTMLEndTag(T); else formTextToken(T, TokenPtr); - return; } @@ -604,7 +612,6 @@ } formTokenWithChars(T, TokenPtr, tok::text); T.setText(Resolved); - return; } void Lexer::setupAndLexHTMLStartTag(Token &T) { @@ -848,4 +855,3 @@ } // end namespace comments } // end namespace clang - Index: cfe/trunk/lib/AST/CommentSema.cpp =================================================================== --- cfe/trunk/lib/AST/CommentSema.cpp +++ cfe/trunk/lib/AST/CommentSema.cpp @@ -23,7 +23,7 @@ namespace { #include "clang/AST/CommentHTMLTagsProperties.inc" -} // unnamed namespace +} // end anonymous namespace Sema::Sema(llvm::BumpPtrAllocator &Allocator, const SourceManager &SourceMgr, DiagnosticsEngine &Diags, CommandTraits &Traits, @@ -353,8 +353,6 @@ << CorrectedName << FixItHint::CreateReplacement(ArgRange, CorrectedName); } - - return; } void Sema::actOnTParamCommandFinish(TParamCommandComment *Command, @@ -1002,7 +1000,7 @@ BestIndex = CurrIndex; } } -} // unnamed namespace +} // end anonymous namespace unsigned Sema::correctTypoInParmVarReference( StringRef Typo, @@ -1040,7 +1038,7 @@ } return false; } -} // unnamed namespace +} // end anonymous namespace bool Sema::resolveTParamReference( StringRef Name, @@ -1067,7 +1065,7 @@ Corrector); } } -} // unnamed namespace +} // end anonymous namespace StringRef Sema::correctTypoInTParamReference( StringRef Typo, @@ -1095,4 +1093,3 @@ } // end namespace comments } // end namespace clang - Index: cfe/trunk/lib/CodeGen/CGClass.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGClass.cpp +++ cfe/trunk/lib/CodeGen/CGClass.cpp @@ -987,7 +987,7 @@ CodeGenFunction &CGF; SanitizerSet OldSanOpts; }; -} +} // end anonymous namespace namespace { class FieldMemcpyizer { @@ -1072,7 +1072,6 @@ const CXXRecordDecl *ClassDecl; private: - void emitMemcpyIR(Address DestPtr, Address SrcPtr, CharUnits Size) { llvm::PointerType *DPT = DestPtr.getType(); llvm::Type *DBP = @@ -1088,13 +1087,12 @@ } void addInitialField(FieldDecl *F) { - FirstField = F; - LastField = F; - FirstFieldOffset = RecLayout.getFieldOffset(F->getFieldIndex()); - LastFieldOffset = FirstFieldOffset; - LastAddedFieldIndex = F->getFieldIndex(); - return; - } + FirstField = F; + LastField = F; + FirstFieldOffset = RecLayout.getFieldOffset(F->getFieldIndex()); + LastFieldOffset = FirstFieldOffset; + LastAddedFieldIndex = F->getFieldIndex(); + } void addNextField(FieldDecl *F) { // For the most part, the following invariant will hold: @@ -1128,7 +1126,6 @@ class ConstructorMemcpyizer : public FieldMemcpyizer { private: - /// Get source argument for copy constructor. Returns null if not a copy /// constructor. static const VarDecl *getTrivialCopySource(CodeGenFunction &CGF, @@ -1233,7 +1230,6 @@ class AssignmentMemcpyizer : public FieldMemcpyizer { private: - // Returns the memcpyable field copied by the given statement, if one // exists. Otherwise returns null. FieldDecl *getMemcpyableField(Stmt *S) { @@ -1307,7 +1303,6 @@ SmallVector AggregatedStmts; public: - AssignmentMemcpyizer(CodeGenFunction &CGF, const CXXMethodDecl *AD, FunctionArgList &Args) : FieldMemcpyizer(CGF, AD->getParent(), Args[Args.size() - 1]), @@ -1630,6 +1625,7 @@ struct CallDtorDeleteConditional final : EHScopeStack::Cleanup { llvm::Value *ShouldDeleteCondition; + public: CallDtorDeleteConditional(llvm::Value *ShouldDeleteCondition) : ShouldDeleteCondition(ShouldDeleteCondition) { @@ -2291,7 +2287,7 @@ /*Delegating=*/false, Addr); } }; -} +} // end anonymous namespace void CodeGenFunction::PushDestructorCleanup(const CXXDestructorDecl *D, Address Addr) { Index: cfe/trunk/lib/CodeGen/CGDecl.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGDecl.cpp +++ cfe/trunk/lib/CodeGen/CGDecl.cpp @@ -29,10 +29,10 @@ #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Type.h" + using namespace clang; using namespace CodeGen; - void CodeGenFunction::EmitDecl(const Decl &D) { switch (D.getKind()) { case Decl::BuiltinTemplate: @@ -527,7 +527,7 @@ CGF.EmitLifetimeEnd(Size, Addr); } }; -} +} // end anonymous namespace /// EmitAutoVarWithLifetime - Does the setup required for an automatic /// variable with lifetime. @@ -645,7 +645,6 @@ } init = castExpr->getSubExpr(); - continue; } return false; } @@ -877,7 +876,6 @@ } } - /// shouldUseMemSetPlusStoresToInitialize - Decide whether we should use memset /// plus some stores to initialize a local variable instead of using a memcpy /// from a constant global. It is beneficial to use memset if the global is all @@ -1163,6 +1161,7 @@ return false; } + void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { assert(emission.Variable && "emission was not valid!"); @@ -1662,7 +1661,7 @@ ElementType, ElementAlign, Destroyer); } }; -} +} // end anonymous namespace /// pushIrregularPartialArrayCleanup - Push an EH cleanup to destroy /// already-constructed elements of the given array. The cleanup @@ -1731,7 +1730,7 @@ CGF.EmitARCRelease(Param, Precise); } }; -} +} // end anonymous namespace /// Emit an alloca (or GlobalValue depending on target) /// for the specified parameter and set up LocalDeclMap. Index: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp +++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp @@ -35,11 +35,9 @@ #include "llvm/Support/Compiler.h" #include - using namespace clang; using namespace CodeGen; - namespace { /// Class that lazily initialises the runtime function. Avoids inserting the /// types and the function declaration into a module if they're not used, and @@ -161,6 +159,7 @@ /// runtime provides some LLVM passes that can use this to do things like /// automatic IMP caching and speculative inlining. unsigned msgSendMDKind; + /// Helper function that generates a constant string and returns a pointer to /// the start of the string. The result of this function can be used anywhere /// where the C code specifies const char*. @@ -170,6 +169,7 @@ return llvm::ConstantExpr::getGetElementPtr(Array.getElementType(), Array.getPointer(), Zeros); } + /// Emits a linkonce_odr string, whose name is the prefix followed by the /// string value. This allows the linker to combine the strings between /// different modules. Used for EH typeinfo names, selector strings, and a @@ -186,6 +186,7 @@ return llvm::ConstantExpr::getGetElementPtr(ConstStr->getValueType(), ConstStr, Zeros); } + /// Generates a global structure, initialized by the elements in the vector. /// The element types must match the types of the structure elements in the /// first argument. @@ -201,6 +202,7 @@ GV->setAlignment(Align.getQuantity()); return GV; } + /// Generates a global array. The vector must contain the same number of /// elements that the array type declares, of the type specified as the array /// element type. @@ -216,6 +218,7 @@ GV->setAlignment(Align.getQuantity()); return GV; } + /// Generates a global array, inferring the array type from the specified /// element type and the size of the initialiser. llvm::GlobalVariable *MakeGlobalArray(llvm::Type *Ty, @@ -227,6 +230,7 @@ llvm::ArrayType *ArrayTy = llvm::ArrayType::get(Ty, V.size()); return MakeGlobal(ArrayTy, V, Align, Name, linkage); } + /// Returns a property name and encoding string. llvm::Constant *MakePropertyEncodingString(const ObjCPropertyDecl *PD, const Decl *Container) { @@ -245,6 +249,7 @@ } return MakeConstantString(PD->getNameAsString()); } + /// Push the property attributes into two structure fields. void PushPropertyAttributes(std::vector &Fields, ObjCPropertyDecl *property, bool isSynthesized=true, bool @@ -273,6 +278,7 @@ Fields.push_back(llvm::ConstantInt::get(Int8Ty, 0)); Fields.push_back(llvm::ConstantInt::get(Int8Ty, 0)); } + /// Ensures that the value has the required type, by inserting a bitcast if /// required. This function lets us avoid inserting bitcasts that are /// redundant. @@ -284,12 +290,14 @@ if (V.getType() == Ty) return V; return B.CreateBitCast(V, Ty); } + // Some zeros used for GEPs in lots of places. llvm::Constant *Zeros[2]; /// Null pointer value. Mainly used as a terminator in various arrays. llvm::Constant *NULLPtr; /// LLVM context. llvm::LLVMContext &VMContext; + private: /// Placeholder for the class. Lots of things refer to the class before we've /// actually emitted it. We use this alias as a placeholder, and then replace @@ -360,7 +368,6 @@ LazyRuntimeFunction SyncExitFn; private: - /// Function called if fast enumeration detects that the collection is /// modified during the update. LazyRuntimeFunction EnumerationMutationFn; @@ -385,7 +392,7 @@ /// Objective-C 1 property structures when targeting the GCC runtime or it /// will abort. const int ProtocolVersion; -private: + /// Generates an instance variable list structure. This is a structure /// containing a size and an array of structures containing instance variable /// metadata. This is used purely for introspection in the fragile ABI. In @@ -393,6 +400,7 @@ llvm::Constant *GenerateIvarList(ArrayRef IvarNames, ArrayRef IvarTypes, ArrayRef IvarOffsets); + /// Generates a method list structure. This is a structure containing a size /// and an array of structures containing method metadata. /// @@ -403,23 +411,28 @@ ArrayRef MethodSels, ArrayRef MethodTypes, bool isClassMethodList); + /// Emits an empty protocol. This is used for \@protocol() where no protocol /// is found. The runtime will (hopefully) fix up the pointer to refer to the /// real protocol. llvm::Constant *GenerateEmptyProtocol(const std::string &ProtocolName); + /// Generates a list of property metadata structures. This follows the same /// pattern as method and instance variable metadata lists. llvm::Constant *GeneratePropertyList(const ObjCImplementationDecl *OID, SmallVectorImpl &InstanceMethodSels, SmallVectorImpl &InstanceMethodTypes); + /// Generates a list of referenced protocols. Classes, categories, and /// protocols all use this structure. llvm::Constant *GenerateProtocolList(ArrayRef Protocols); + /// To ensure that all protocols are seen by the runtime, we add a category on /// a class defined in the runtime, declaring no methods, but adopting the /// protocols. This is a horribly ugly hack, but it allows us to collect all /// of the protocols without changing the ABI. void GenerateProtocolHolderCategory(); + /// Generates a class structure. llvm::Constant *GenerateClassStructure( llvm::Constant *MetaClass, @@ -436,25 +449,31 @@ llvm::Constant *StrongIvarBitmap, llvm::Constant *WeakIvarBitmap, bool isMeta=false); + /// Generates a method list. This is used by protocols to define the required /// and optional methods. llvm::Constant *GenerateProtocolMethodList( ArrayRef MethodNames, ArrayRef MethodTypes); + /// Returns a selector with the specified type encoding. An empty string is /// used to return an untyped selector (with the types field set to NULL). llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel, const std::string &TypeEncoding); + /// Returns the variable used to store the offset of an instance variable. llvm::GlobalVariable *ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar); /// Emits a reference to a class. This allows the linker to object if there /// is no class of the matching name. + protected: void EmitClassRef(const std::string &className); + /// Emits a pointer to the named class virtual llvm::Value *GetClassNamed(CodeGenFunction &CGF, const std::string &Name, bool isWeak); + /// Looks up the method for sending a message to the specified object. This /// mechanism differs between the GCC and GNU runtimes, so this method must be /// overridden in subclasses. @@ -463,6 +482,7 @@ llvm::Value *cmd, llvm::MDNode *node, MessageSendInfo &MSI) = 0; + /// Looks up the method for sending a message to a superclass. This /// mechanism differs between the GCC and GNU runtimes, so this method must /// be overridden in subclasses. @@ -470,6 +490,7 @@ Address ObjCSuper, llvm::Value *cmd, MessageSendInfo &MSI) = 0; + /// Libobjc2 uses a bitfield representation where small(ish) bitfields are /// stored in a 64-bit value with the low bit set to 1 and the remaining 63 /// bits set to their values, LSB first, while larger ones are stored in a @@ -482,6 +503,7 @@ /// a bitfield with the 64th bit set will be (int64_t)&{ 2, [0, 1<<31] }, /// while a bitfield / with the 63rd bit set will be 1<<64. llvm::Constant *MakeBitField(ArrayRef bits); + public: CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, unsigned protocolClassVersion); @@ -574,6 +596,7 @@ return nullptr; } }; + /// Class representing the legacy GCC Objective-C ABI. This is the default when /// -fobjc-nonfragile-abi is not specified. /// @@ -590,6 +613,7 @@ /// structure describing the receiver and the class, and a selector as /// arguments. Returns the IMP for the corresponding method. LazyRuntimeFunction MsgLookupSuperFn; + protected: llvm::Value *LookupIMP(CodeGenFunction &CGF, llvm::Value *&Receiver, llvm::Value *cmd, llvm::MDNode *node, @@ -602,23 +626,26 @@ imp->setMetadata(msgSendMDKind, node); return imp.getInstruction(); } + llvm::Value *LookupIMPSuper(CodeGenFunction &CGF, Address ObjCSuper, llvm::Value *cmd, MessageSendInfo &MSI) override { - CGBuilderTy &Builder = CGF.Builder; - llvm::Value *lookupArgs[] = {EnforceType(Builder, ObjCSuper, - PtrToObjCSuperTy).getPointer(), cmd}; - return CGF.EmitNounwindRuntimeCall(MsgLookupSuperFn, lookupArgs); - } - public: - CGObjCGCC(CodeGenModule &Mod) : CGObjCGNU(Mod, 8, 2) { - // IMP objc_msg_lookup(id, SEL); - MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, - nullptr); - // IMP objc_msg_lookup_super(struct objc_super*, SEL); - MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy, - PtrToObjCSuperTy, SelectorTy, nullptr); - } + CGBuilderTy &Builder = CGF.Builder; + llvm::Value *lookupArgs[] = {EnforceType(Builder, ObjCSuper, + PtrToObjCSuperTy).getPointer(), cmd}; + return CGF.EmitNounwindRuntimeCall(MsgLookupSuperFn, lookupArgs); + } + +public: + CGObjCGCC(CodeGenModule &Mod) : CGObjCGNU(Mod, 8, 2) { + // IMP objc_msg_lookup(id, SEL); + MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, + nullptr); + // IMP objc_msg_lookup_super(struct objc_super*, SEL); + MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy, + PtrToObjCSuperTy, SelectorTy, nullptr); + } }; + /// Class used when targeting the new GNUstep runtime ABI. class CGObjCGNUstep : public CGObjCGNU { /// The slot lookup function. Returns a pointer to a cacheable structure @@ -646,8 +673,10 @@ /// Type of an slot structure pointer. This is returned by the various /// lookup functions. llvm::Type *SlotTy; + public: llvm::Constant *GetEHType(QualType T) override; + protected: llvm::Value *LookupIMP(CodeGenFunction &CGF, llvm::Value *&Receiver, llvm::Value *cmd, llvm::MDNode *node, @@ -689,6 +718,7 @@ Receiver = Builder.CreateLoad(ReceiverPtr, true); return imp; } + llvm::Value *LookupIMPSuper(CodeGenFunction &CGF, Address ObjCSuper, llvm::Value *cmd, MessageSendInfo &MSI) override { @@ -702,6 +732,7 @@ return Builder.CreateAlignedLoad(Builder.CreateStructGEP(nullptr, slot, 4), CGF.getPointerAlign()); } + public: CGObjCGNUstep(CodeGenModule &Mod) : CGObjCGNU(Mod, 9, 3) { const ObjCRuntime &R = CGM.getLangOpts().ObjCRuntime; @@ -753,6 +784,7 @@ CxxAtomicObjectGetFn.init(&CGM, "objc_getCppObjectAtomic", VoidTy, PtrTy, PtrTy, PtrTy, nullptr); } + llvm::Constant *GetCppAtomicObjectGetFunction() override { // The optimised functions were added in version 1.7 of the GNUstep // runtime. @@ -760,6 +792,7 @@ VersionTuple(1, 7)); return CxxAtomicObjectGetFn; } + llvm::Constant *GetCppAtomicObjectSetFunction() override { // The optimised functions were added in version 1.7 of the GNUstep // runtime. @@ -767,6 +800,7 @@ VersionTuple(1, 7)); return CxxAtomicObjectSetFn; } + llvm::Constant *GetOptimizedPropertySetFunction(bool atomic, bool copy) override { // The optimised property functions omit the GC check, and so are not @@ -865,7 +899,6 @@ }; } // 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. @@ -1046,13 +1079,13 @@ const ObjCInterfaceDecl *OID) { return GetClassNamed(CGF, OID->getNameAsString(), OID->isWeakImported()); } + llvm::Value *CGObjCGNU::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) { return GetClassNamed(CGF, "NSAutoreleasePool", false); } llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF, Selector Sel, const std::string &TypeEncoding) { - SmallVectorImpl &Types = SelectorTable[Sel]; llvm::GlobalAlias *SelValue = nullptr; @@ -1247,8 +1280,6 @@ } llvm::Value *cmd = GetSelector(CGF, Sel); - - CallArgList ActualArgs; ActualArgs.add(RValue::get(EnforceType(Builder, Receiver, IdTy)), ASTIdTy); @@ -2256,7 +2287,6 @@ MakeGlobalArray(PtrToIntTy, IvarOffsetValues, CGM.getPointerAlign(), ".ivar.offsets"); - // Collect information about instance methods SmallVector InstanceMethodSels; SmallVector InstanceMethodTypes; @@ -2270,7 +2300,6 @@ llvm::Constant *Properties = GeneratePropertyList(OID, InstanceMethodSels, InstanceMethodTypes); - // Collect information about class methods SmallVector ClassMethodSels; SmallVector ClassMethodTypes; @@ -2376,7 +2405,6 @@ Classes.push_back(ClassStruct); } - llvm::Function *CGObjCGNU::ModuleInitFunction() { // Only emit an ObjC load function if no Objective-C stuff has been called if (Classes.empty() && Categories.empty() && ConstantStrings.empty() && @@ -2651,12 +2679,15 @@ llvm::Constant *CGObjCGNU::GetGetStructFunction() { return GetStructPropertyFn; } + llvm::Constant *CGObjCGNU::GetSetStructFunction() { return SetStructPropertyFn; } + llvm::Constant *CGObjCGNU::GetCppAtomicObjectGetFunction() { return nullptr; } + llvm::Constant *CGObjCGNU::GetCppAtomicObjectSetFunction() { return nullptr; } @@ -2685,7 +2716,6 @@ // In Objective-C++ mode, we actually emit something equivalent to the C++ // exception handler. EmitTryCatchStmt(CGF, S, EnterCatchFn, ExitCatchFn, ExceptionReThrowFn); - return ; } void CGObjCGNU::EmitThrowStmt(CodeGenFunction &CGF, Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp @@ -576,7 +576,6 @@ return CGM.CreateRuntimeFunction( llvm::FunctionType::get(CGM.Int32Ty, params, false), "objc_exception_match"); - } /// SetJmpFn - LLVM _setjmp function. @@ -600,7 +599,6 @@ /// modern abi class ObjCNonFragileABITypesHelper : public ObjCCommonTypesHelper { public: - // MethodListnfABITy - LLVM for struct _method_list_t llvm::StructType *MethodListnfABITy; @@ -1509,12 +1507,15 @@ llvm::Constant *GetSetStructFunction() override { return ObjCTypes.getCopyStructFn(); } + llvm::Constant *GetGetStructFunction() override { return ObjCTypes.getCopyStructFn(); } + llvm::Constant *GetCppAtomicObjectSetFunction() override { return ObjCTypes.getCppAtomicObjectFunction(); } + llvm::Constant *GetCppAtomicObjectGetFunction() override { return ObjCTypes.getCppAtomicObjectFunction(); } @@ -2030,6 +2031,7 @@ bool IsDisordered = false; llvm::SmallVector IvarsInfo; + public: IvarLayoutBuilder(CodeGenModule &CGM, CharUnits instanceBegin, CharUnits instanceEnd, bool forStrongLayout) @@ -2065,7 +2067,7 @@ printf("\n"); } }; -} +} // end anonymous namespace llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM, const CGBlockInfo &blockInfo) { @@ -2144,7 +2146,6 @@ } } - /// getBlockCaptureLifetime - This routine returns life time of the captured /// block variable for the purpose of block layout meta-data generation. FQT is /// the type of the variable captured in the block. @@ -2632,7 +2633,6 @@ return getBitmapBlockLayout(false); } - llvm::Constant *CGObjCCommonMac::BuildByrefLayout(CodeGen::CodeGenModule &CGM, QualType T) { assert(CGM.getLangOpts().getGC() == LangOptions::NonGC); @@ -3640,6 +3640,7 @@ llvm::Constant *CGObjCMac::GetGetStructFunction() { return ObjCTypes.getCopyStructFn(); } + llvm::Constant *CGObjCMac::GetSetStructFunction() { return ObjCTypes.getCopyStructFn(); } @@ -3647,6 +3648,7 @@ llvm::Constant *CGObjCMac::GetCppAtomicObjectGetFunction() { return ObjCTypes.getCppAtomicObjectFunction(); } + llvm::Constant *CGObjCMac::GetCppAtomicObjectSetFunction() { return ObjCTypes.getCppAtomicObjectFunction(); } @@ -3744,7 +3746,7 @@ void emitWriteHazard(); void emitHazardsInNewBlocks(); }; -} +} // end anonymous namespace /// Create the fragile-ABI read and write hazards based on the current /// state of the function, which is presumed to be immediately prior @@ -4365,7 +4367,6 @@ llvm::Value *args[] = { src, dst.getPointer() }; CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), args, "weakassign"); - return; } /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. @@ -4391,7 +4392,6 @@ else CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), args, "threadlocalassign"); - return; } /// EmitObjCIvarAssign - Code gen for assigning to a __strong object. @@ -4413,7 +4413,6 @@ dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy); llvm::Value *args[] = { src, dst.getPointer(), ivarOffset }; CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignIvarFn(), args); - return; } /// EmitObjCStrongCastAssign - Code gen for assigning to a __strong cast object. @@ -4434,7 +4433,6 @@ llvm::Value *args[] = { src, dst.getPointer() }; CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), args, "strongassign"); - return; } void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, @@ -5261,7 +5259,6 @@ // struct _objc_cache * CacheTy = llvm::StructType::create(VMContext, "struct._objc_cache"); CachePtrTy = llvm::PointerType::getUnqual(CacheTy); - } ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) @@ -5447,7 +5444,6 @@ llvm::StructType::create("struct._objc_exception_data", llvm::ArrayType::get(CGM.Int32Ty,SetJmpBufferSize), StackPtrTy, nullptr); - } ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModule &cgm) Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp @@ -100,6 +100,7 @@ ThreadIDVar(ThreadIDVar) { assert(ThreadIDVar != nullptr && "No ThreadID in OpenMP region."); } + /// \brief Get a variable or parameter for storing global thread id /// inside OpenMP construct. const VarDecl *getThreadIDVariable() const override { return ThreadIDVar; } @@ -130,6 +131,7 @@ ThreadIDVar(ThreadIDVar) { assert(ThreadIDVar != nullptr && "No ThreadID in OpenMP region."); } + /// \brief Get a variable or parameter for storing global thread id /// inside OpenMP construct. const VarDecl *getThreadIDVariable() const override { return ThreadIDVar; } @@ -162,12 +164,14 @@ : CGOpenMPRegionInfo(InlinedRegion, CodeGen, Kind, HasCancel), OldCSI(OldCSI), OuterRegionInfo(dyn_cast_or_null(OldCSI)) {} + // \brief Retrieve the value of the context parameter. llvm::Value *getContextValue() const override { if (OuterRegionInfo) return OuterRegionInfo->getContextValue(); llvm_unreachable("No context value for inlined OpenMP region"); } + void setContextValue(llvm::Value *V) override { if (OuterRegionInfo) { OuterRegionInfo->setContextValue(V); @@ -175,6 +179,7 @@ } llvm_unreachable("No context value for inlined OpenMP region"); } + /// \brief Lookup the captured field decl for a variable. const FieldDecl *lookup(const VarDecl *VD) const override { if (OuterRegionInfo) @@ -183,11 +188,13 @@ // captured variables, we can use the original one. return nullptr; } + FieldDecl *getThisFieldDecl() const override { if (OuterRegionInfo) return OuterRegionInfo->getThisFieldDecl(); return nullptr; } + /// \brief Get a variable or parameter for storing global thread id /// inside OpenMP construct. const VarDecl *getThreadIDVariable() const override { @@ -261,6 +268,7 @@ CGF.CapturedStmtInfo = new CGOpenMPInlinedRegionInfo( CGF.CapturedStmtInfo, CodeGen, Kind, HasCancel); } + ~InlinedOpenMPRegionRAII() { // Restore original CapturedStmtInfo only if we're done with code emission. auto *OldCSI = @@ -1379,6 +1387,7 @@ assert(CleanupArgs.size() == N); std::copy(CleanupArgs.begin(), CleanupArgs.end(), std::begin(Args)); } + void Emit(CodeGenFunction &CGF, Flags /*flags*/) override { if (!CGF.HaveInsertPoint()) return; @@ -2209,7 +2218,6 @@ // We can't have any padding between symbols, so we need to have 1-byte // alignment. Entry->setAlignment(1); - return; } void CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata() { @@ -3591,7 +3599,7 @@ CancelSections = 3, CancelTaskgroup = 4 }; -} +} // anonymous namespace static RTCancelKind getCancellationKind(OpenMPDirectiveKind CancelRegion) { RTCancelKind CancelKind = CancelNoreq; @@ -3711,14 +3719,12 @@ FileID = ID.getFile(); LineNum = PLoc.getLine(); ColumnNum = PLoc.getColumn(); - return; } void CGOpenMPRuntime::emitTargetOutlinedFunction( const OMPExecutableDirective &D, StringRef ParentName, llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID, bool IsOffloadEntry) { - assert(!ParentName.empty() && "Invalid target region parent name!"); const CapturedStmt &CS = *cast(D.getAssociatedStmt()); @@ -3787,7 +3793,6 @@ // Register the information for the entry associated with this target region. OffloadEntriesInfoManager.registerTargetRegionEntryInfo( DeviceID, FileID, ParentName, Line, Column, OutlinedFn, OutlinedFnID); - return; } void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF, @@ -3975,7 +3980,6 @@ MapTypesArray = MapTypesArrayGbl; for (unsigned i = 0; i < PointerNumVal; ++i) { - llvm::Value *BPVal = BasePointers[i]; if (BPVal->getType()->isPointerTy()) BPVal = CGF.Builder.CreateBitCast(BPVal, CGM.VoidPtrTy); @@ -4103,7 +4107,6 @@ CGF.EmitBranch(OffloadContBlock); CGF.EmitBlock(OffloadContBlock, /*IsFinished=*/true); - return; } void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S, @@ -4156,8 +4159,6 @@ // Keep looking for target regions recursively. for (auto *II : S->children()) scanForTargetRegionsFunctions(II, ParentName); - - return; } bool CGOpenMPRuntime::emitTargetFunctions(GlobalDecl GD) { Index: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp =================================================================== --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -135,7 +135,6 @@ SmallVector BlockDeclRefs; - // Block related declarations. SmallVector BlockByCopyDecls; llvm::SmallPtrSet BlockByCopyDeclsPtrSet; @@ -186,6 +185,7 @@ public: llvm::DenseMap MethodInternalNames; + // Top Level Driver code. bool HandleTopLevelDecl(DeclGroupRef D) override { for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) { @@ -235,7 +235,6 @@ RewriteObjCQualifiedInterfaceTypes(TD); } } - return; } void HandleTopLevelSingleDecl(Decl *D); @@ -562,6 +561,7 @@ } return false; } + bool PointerTypeTakesAnyBlockArguments(QualType QT); bool PointerTypeTakesAnyObjCQualifiedType(QualType QT); void GetExtentOfArgList(const char *Name, const char *&LParen, @@ -608,8 +608,7 @@ /*Pascal=*/false, StrType, SourceLocation()); } }; - -} +} // end anonymous namespace void RewriteModernObjC::RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D) { @@ -853,7 +852,6 @@ else WriteInternalIvarName(ClassDecl, D, IvarOffsetName); - std::string S = "(*("; QualType IvarT = D->getType(); if (D->isBitField()) @@ -1068,11 +1066,11 @@ void RewriteModernObjC::RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl, const std::string &typedefString) { - SourceLocation startLoc = ClassDecl->getLocStart(); - const char *startBuf = SM->getCharacterData(startLoc); - const char *semiPtr = strchr(startBuf, ';'); - // Replace the @class with typedefs corresponding to the classes. - ReplaceText(startLoc, semiPtr-startBuf+1, typedefString); + SourceLocation startLoc = ClassDecl->getLocStart(); + const char *startBuf = SM->getCharacterData(startLoc); + const char *semiPtr = strchr(startBuf, ';'); + // Replace the @class with typedefs corresponding to the classes. + ReplaceText(startLoc, semiPtr-startBuf+1, typedefString); } void RewriteModernObjC::RewriteForwardClassDecl(DeclGroupRef D) { @@ -1354,6 +1352,7 @@ } } } + void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) { ObjCImplementationDecl *IMD = dyn_cast(OID); ObjCCategoryImplDecl *CID = dyn_cast(OID); @@ -1940,7 +1939,6 @@ Diags.Report(Context->getFullLoc(S->getLocStart()), TryFinallyContainsReturnDiag); } - return; } Stmt *RewriteModernObjC::RewriteObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { @@ -2809,7 +2807,6 @@ Context->UnsignedIntTy, SourceLocation()); MsgExprs.push_back(cnt); - SmallVector ArgTypes; ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); @@ -2921,8 +2918,6 @@ CK_BitCast, DictLiteralKeyME); - - // Synthesize a call to objc_msgSend(). SmallVector MsgExprs; SmallVector ClsExprs; @@ -2959,7 +2954,6 @@ Context->UnsignedIntTy, SourceLocation()); MsgExprs.push_back(cnt); - SmallVector ArgTypes; ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); @@ -3176,7 +3170,6 @@ str += "\t memset((void*)&s, 0, sizeof(s));\n"; str += "\t else\n"; - str += "\t s = (("; str += castType.getAsString(Context->getPrintingPolicy()); str += ")(void *)objc_msgSend_stret)(receiver, sel"; for (unsigned i = 2; i < ArgTypes.size(); i++) { @@ -3188,7 +3181,6 @@ } str += ");\n"; - str += "\t}\n"; str += "\t"; str += returnType.getAsString(Context->getPrintingPolicy()); str += " s;\n"; @@ -3635,7 +3627,6 @@ ProtocolExprDecls.insert(Exp->getProtocol()->getCanonicalDecl()); // delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info. return castExpr; - } bool RewriteModernObjC::BufferContainsPPDirectives(const char *startBuf, @@ -3688,7 +3679,6 @@ TagLocation = ED->getLocation(); return Context->getSourceManager().isBeforeInTranslationUnit( IDecl->getLocation(), TagLocation); - } return false; } @@ -3820,7 +3810,6 @@ if (IsNamedDefinition) GlobalDefinedTags.insert(TD); } - } unsigned RewriteModernObjC::ObjCIvarBitfieldGroupNo(ObjCIvarDecl *IV) { @@ -3911,7 +3900,6 @@ Result += "__GRBF_"; unsigned GroupNo = ObjCIvarBitfieldGroupNo(IV); Result += utostr(GroupNo); - return; } /// ObjCIvarBitfieldGroupType - Names struct type for ivar bitfield group. @@ -3924,7 +3912,6 @@ Result += "__T_"; unsigned GroupNo = ObjCIvarBitfieldGroupNo(IV); Result += utostr(GroupNo); - return; } /// ObjCIvarBitfieldGroupOffset - Names symbol for ivar bitfield group field offset. @@ -4063,7 +4050,6 @@ // Meta Data Emission //===----------------------------------------------------------------------===// - /// RewriteImplementations - This routine rewrites all method implementations /// and emits meta-data. @@ -4543,8 +4529,6 @@ HasLocalVariableExternalStorage(DRE->getDecl())) // FIXME: Handle enums. BlockDeclRefs.push_back(DRE); - - return; } void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S, @@ -4572,8 +4556,6 @@ ImportedLocalExternalDecls.insert(Var); } } - - return; } /// convertObjCTypeToCStyleType - This routine converts such objc types @@ -4828,7 +4810,6 @@ break; } } - return; } void RewriteModernObjC::RewriteImplicitCastObjCExpr(CastExpr *IC) { @@ -4844,8 +4825,6 @@ Str += TypeString; Str += ")"; InsertText(IC->getSubExpr()->getLocStart(), Str); - - return; } void RewriteModernObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) { @@ -4880,7 +4859,6 @@ break; } } - return; } bool RewriteModernObjC::PointerTypeTakesAnyBlockArguments(QualType QT) { @@ -5017,11 +4995,8 @@ OrigLength++; } ReplaceText(Start, OrigLength, buf); - - return; } - /// SynthesizeByrefCopyDestroyHelper - This routine synthesizes: /// void __Block_byref_id_object_copy(struct Block_byref_id_object *dst, /// struct Block_byref_id_object *src) { @@ -5242,7 +5217,6 @@ InsertText(separatorLoc, lastDecl ? "}" : "};\n"); } - return; } void RewriteModernObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) { @@ -5284,7 +5258,6 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, const SmallVectorImpl &InnerBlockDeclRefs) { - const BlockDecl *block = Exp->getBlockDecl(); Blocks.push_back(Exp); @@ -5292,7 +5265,7 @@ CollectBlockDeclRefInfo(Exp); // Add inner imported variables now used in current block. - int countOfInnerDecls = 0; + int countOfInnerDecls = 0; if (!InnerBlockDeclRefs.empty()) { for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) { DeclRefExpr *Exp = InnerBlockDeclRefs[i]; @@ -7073,7 +7046,6 @@ // Mark this protocol as having been generated. if (!ObjCSynthesizedProtocols.insert(PDecl->getCanonicalDecl()).second) llvm_unreachable("protocol already synthesized"); - } void RewriteModernObjC::RewriteObjCProtocolListMetaData( @@ -7215,14 +7187,12 @@ /* Container */IDecl, "_OBJC_$_PROP_LIST_", CDecl->getNameAsString()); - // Data for initializing _class_ro_t metaclass meta-data uint32_t flags = CLS_META; std::string InstanceSize; std::string InstanceStart; - bool classIsHidden = CDecl->getVisibility() == HiddenVisibility; if (classIsHidden) flags |= OBJC2_CLS_HIDDEN; @@ -7290,7 +7260,6 @@ if (ImplementationIsNonLazy(IDecl)) DefinedNonLazyClasses.push_back(CDecl); - } void RewriteModernObjC::RewriteClassSetupInitHook(std::string &Result) { @@ -7473,7 +7442,6 @@ // Determine if this category is also "non-lazy". if (ImplementationIsNonLazy(IDecl)) DefinedNonLazyCategories.push_back(CDecl); - } void RewriteModernObjC::RewriteCategorySetupInitHook(std::string &Result) { @@ -7708,4 +7676,4 @@ return Replacement; } -#endif +#endif // CLANG_ENABLE_OBJC_REWRITER Index: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp =================================================================== --- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp +++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -37,7 +37,6 @@ namespace { class RewriteObjC : public ASTConsumer { protected: - enum { BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)), block, ... */ @@ -158,14 +157,15 @@ : R(R), SavedValue(R.DisableReplaceStmt) { R.DisableReplaceStmt = true; } + ~DisableReplaceStmtScope() { R.DisableReplaceStmt = SavedValue; } }; + void InitializeCommon(ASTContext &context); public: - // Top Level Driver code. bool HandleTopLevelDecl(DeclGroupRef D) override { for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) { @@ -187,6 +187,7 @@ } return true; } + void HandleTopLevelSingleDecl(Decl *D); void HandleDeclInMainFile(Decl *D); RewriteObjC(std::string inFile, raw_ostream *OS, @@ -505,7 +506,6 @@ class RewriteObjCFragileABI : public RewriteObjC { public: - RewriteObjCFragileABI(std::string inFile, raw_ostream *OS, DiagnosticsEngine &D, const LangOptions &LOpts, bool silenceMacroWarn) : RewriteObjC(inFile, OS, @@ -540,7 +540,7 @@ std::string &Result) override; Stmt *RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) override; }; -} +} // end anonymous namespace void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D) { @@ -1159,6 +1159,7 @@ } } } + void RewriteObjC::RewriteImplementationDecl(Decl *OID) { ObjCImplementationDecl *IMD = dyn_cast(OID); ObjCCategoryImplDecl *CID = dyn_cast(OID); @@ -1720,7 +1721,6 @@ Diags.Report(Context->getFullLoc(S->getLocStart()), TryFinallyContainsReturnDiag); } - return; } void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns) @@ -1730,32 +1730,29 @@ if (SubStmt) HasReturnStmts(SubStmt, hasReturns); - if (isa(S)) - hasReturns = true; - return; + if (isa(S)) + hasReturns = true; } void RewriteObjC::RewriteTryReturnStmts(Stmt *S) { - // Perform a bottom up traversal of all children. - for (Stmt *SubStmt : S->children()) - if (SubStmt) { - RewriteTryReturnStmts(SubStmt); - } - if (isa(S)) { - SourceLocation startLoc = S->getLocStart(); - const char *startBuf = SM->getCharacterData(startLoc); - - const char *semiBuf = strchr(startBuf, ';'); - assert((*semiBuf == ';') && "RewriteTryReturnStmts: can't find ';'"); - SourceLocation onePastSemiLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1); + // Perform a bottom up traversal of all children. + for (Stmt *SubStmt : S->children()) + if (SubStmt) { + RewriteTryReturnStmts(SubStmt); + } + if (isa(S)) { + SourceLocation startLoc = S->getLocStart(); + const char *startBuf = SM->getCharacterData(startLoc); + const char *semiBuf = strchr(startBuf, ';'); + assert((*semiBuf == ';') && "RewriteTryReturnStmts: can't find ';'"); + SourceLocation onePastSemiLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1); - std::string buf; - buf = "{ objc_exception_try_exit(&_stack); return"; + std::string buf; + buf = "{ objc_exception_try_exit(&_stack); return"; - ReplaceText(startLoc, 6, buf); - InsertText(onePastSemiLoc, "}"); - } - return; + ReplaceText(startLoc, 6, buf); + InsertText(onePastSemiLoc, "}"); + } } void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) { @@ -1780,7 +1777,6 @@ ReplaceText(startLoc, 6, buf); InsertText(onePastSemiLoc, "}"); } - return; } Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) { @@ -2287,7 +2283,6 @@ } } - void RewriteObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) { SourceLocation FunLocStart = FD->getTypeSpecStartLoc(); const FunctionType *funcType = FD->getType()->getAs(); @@ -2615,10 +2610,8 @@ CallExpr *STCE = new (Context) CallExpr( *Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, SourceLocation()); return STCE; - } - Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SourceLocation StartLoc, SourceLocation EndLoc) { @@ -3059,7 +3052,6 @@ ProtocolExprDecls.insert(Exp->getProtocol()->getCanonicalDecl()); // delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info. return castExpr; - } bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf, @@ -3224,7 +3216,6 @@ // Meta Data Emission //===----------------------------------------------------------------------===// - /// RewriteImplementations - This routine rewrites all method implementations /// and emits meta-data. @@ -3665,8 +3656,6 @@ HasLocalVariableExternalStorage(DRE->getDecl())) // FIXME: Handle enums. BlockDeclRefs.push_back(DRE); - - return; } void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, @@ -3694,8 +3683,6 @@ ImportedLocalExternalDecls.insert(Var); } } - - return; } /// convertFunctionTypeOfBlocks - This routine converts a function type @@ -3931,7 +3918,6 @@ break; } } - return; } void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) { @@ -3966,7 +3952,6 @@ break; } } - return; } bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) { @@ -4103,11 +4088,8 @@ OrigLength++; } ReplaceText(Start, OrigLength, buf); - - return; } - /// SynthesizeByrefCopyDestroyHelper - This routine synthesizes: /// void __Block_byref_id_object_copy(struct Block_byref_id_object *dst, /// struct Block_byref_id_object *src) { @@ -4328,7 +4310,6 @@ InsertText(semiLoc, "}"); } - return; } void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) { @@ -4494,7 +4475,6 @@ Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, QT, VK_RValue, OK_Ordinary, SourceLocation()); } - } InitExprs.push_back(Exp); } @@ -5241,7 +5221,6 @@ // Mark this protocol as having been generated. if (!ObjCSynthesizedProtocols.insert(PDecl->getCanonicalDecl()).second) llvm_unreachable("protocol already synthesized"); - } void RewriteObjCFragileABI::RewriteObjCProtocolListMetaData( @@ -5910,4 +5889,4 @@ return Replacement; } -#endif +#endif // CLANG_ENABLE_OBJC_REWRITER Index: cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -132,7 +132,7 @@ void checkPostStmt(const ObjCArrayLiteral *AL, CheckerContext &C) const; }; -} +} // end anonymous namespace void NilArgChecker::warnIfNilExpr(const Expr *E, const char *Msg, @@ -143,7 +143,6 @@ if (ExplodedNode *N = C.generateErrorNode()) { generateBugReport(N, Msg, E->getSourceRange(), E, C); } - } } @@ -530,6 +529,7 @@ class CFRetainReleaseChecker : public Checker< check::PreStmt > { mutable std::unique_ptr BT; mutable IdentifierInfo *Retain, *Release, *MakeCollectable, *Autorelease; + public: CFRetainReleaseChecker() : Retain(nullptr), Release(nullptr), MakeCollectable(nullptr), @@ -538,7 +538,6 @@ }; } // end anonymous namespace - void CFRetainReleaseChecker::checkPreStmt(const CallExpr *CE, CheckerContext &C) const { // If the CallExpr doesn't have exactly 1 argument just give up checking. @@ -631,11 +630,10 @@ public: void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const; }; -} +} // end anonymous namespace void ClassReleaseChecker::checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const { - if (!BT) { BT.reset(new APIMisuse( this, "message incorrectly sent to class instead of class instance")); @@ -692,7 +690,7 @@ public: void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const; }; -} +} // end anonymous namespace /// isVariadicMessage - Returns whether the given message is a variadic message, /// where all arguments must be Objective-C types. @@ -855,7 +853,7 @@ const CallEvent *Call, PointerEscapeKind Kind) const; }; -} +} // end anonymous namespace static bool isKnownNonNilCollectionType(QualType T) { const ObjCObjectPointerType *PT = T->getAs(); @@ -983,7 +981,6 @@ return assumeCollectionNonEmpty(C, State, CollectionS, Assumption); } - /// If the fist block edge is a back edge, we are reentering the loop. static bool alreadyExecutedAtLeastOneLoopIteration(const ExplodedNode *N, const ObjCForCollectionStmt *FCS) { @@ -1080,7 +1077,6 @@ C.addTransition(State); } - return; } static SymbolRef getMethodReceiverIfKnownImmutable(const CallEvent *Call) { @@ -1203,7 +1199,7 @@ void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const; }; -} +} // end anonymous namespace ProgramStateRef ObjCNonNilReturnValueChecker::assumeExprIsNonNull(const Expr *NonNullExpr, Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp @@ -1,4 +1,4 @@ -//= CheckerDocumentation.cpp - Documentation checker ---------------*- C++ -*-// +//===- CheckerDocumentation.cpp - Documentation checker ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -57,7 +57,6 @@ check::Event, check::ASTDecl > { public: - /// \brief Pre-visit the Statement. /// /// The method will be called before the analyzer core processes the @@ -147,7 +146,6 @@ /// check::Bind void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &) const {} - /// \brief Called whenever a symbol becomes dead. /// /// This callback should be used by the checkers to aggressively clean @@ -190,7 +188,6 @@ AnalysisManager &Mgr, BugReporter &BR) const {} - /// \brief Evaluates function call. /// /// The analysis core threats all function calls in the same way. However, some @@ -310,12 +307,10 @@ void checkASTDecl(const FunctionDecl *D, AnalysisManager &Mgr, BugReporter &BR) const {} - }; void CheckerDocumentation::checkPostStmt(const DeclStmt *DS, CheckerContext &C) const { - return; } } // end namespace ento Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp @@ -1,4 +1,4 @@ -//===- Chrootchecker.cpp -------- Basic security checks ----------*- C++ -*-==// +//===- Chrootchecker.cpp -------- Basic security checks ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -20,6 +20,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" #include "llvm/ADT/ImmutableMap.h" + using namespace clang; using namespace ento; @@ -148,8 +149,6 @@ C.emitReport(llvm::make_unique( *BT_BreakJail, BT_BreakJail->getDescription(), N)); } - - return; } void ento::registerChrootChecker(CheckerManager &mgr) { Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -1,4 +1,4 @@ -//== DynamicTypePropagation.cpp -------------------------------- -*- C++ -*--=// +//===- DynamicTypePropagation.cpp ------------------------------*- C++ -*--===// // // The LLVM Compiler Infrastructure // @@ -97,6 +97,7 @@ const ObjCObjectPointerType *To, ExplodedNode *N, SymbolRef Sym, CheckerContext &C, const Stmt *ReportedNode = nullptr) const; + public: void checkPreCall(const CallEvent &Call, CheckerContext &C) const; void checkPostCall(const CallEvent &Call, CheckerContext &C) const; @@ -109,7 +110,7 @@ /// This value is set to true, when the Generics checker is turned on. DefaultBool CheckGenerics; }; -} +} // end anonymous namespace void DynamicTypePropagation::checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const { @@ -151,7 +152,6 @@ ProgramStateRef State = C.getState(); State = setDynamicTypeInfo(State, Region, Ty, /*CanBeSubclass=*/false); C.addTransition(State); - return; } void DynamicTypePropagation::checkPreCall(const CallEvent &Call, @@ -772,7 +772,6 @@ // class. This method is provided by the runtime and available on all classes. if (MessageExpr->getReceiverKind() == ObjCMessageExpr::Class && Sel.getAsString() == "class") { - QualType ReceiverType = MessageExpr->getClassReceiver(); const auto *ReceiverClassType = ReceiverType->getAs(); QualType ReceiverClassPointerType = Index: cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp @@ -1,4 +1,4 @@ -//=- IvarInvalidationChecker.cpp - -*- C++ -------------------------------*-==// +//===- IvarInvalidationChecker.cpp ------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -43,7 +43,6 @@ using namespace ento; namespace { - struct ChecksFilter { /// Check for missing invalidation method declarations. DefaultBool check_MissingInvalidationMethod; @@ -55,7 +54,6 @@ }; class IvarInvalidationCheckerImpl { - typedef llvm::SmallSetVector MethodSet; typedef llvm::DenseMap MethToIvarMapTy; @@ -64,7 +62,6 @@ typedef llvm::DenseMap IvarToPropMapTy; - struct InvalidationInfo { /// Has the ivar been invalidated? bool IsInvalidated; @@ -167,7 +164,7 @@ void VisitObjCMessageExpr(const ObjCMessageExpr *ME); void VisitChildren(const Stmt *S) { - for (const Stmt *Child : S->children()) { + for (const auto *Child : S->children()) { if (Child) this->Visit(Child); if (CalledAnotherInvalidationMethod) @@ -208,6 +205,7 @@ const IvarToPropMapTy &IvarToPopertyMap, const ObjCInterfaceDecl *InterfaceD, bool MissingDeclaration) const; + void reportIvarNeedsInvalidation(const ObjCIvarDecl *IvarD, const IvarToPropMapTy &IvarToPopertyMap, const ObjCMethodDecl *MethodD) const; @@ -276,8 +274,6 @@ } return; } - - return; } bool IvarInvalidationCheckerImpl::trackIvar(const ObjCIvarDecl *Iv, @@ -724,11 +720,10 @@ VisitStmt(ME); } -} +} // end anonymous namespace // Register the checkers. namespace { - class IvarInvalidationChecker : public Checker > { public: @@ -740,7 +735,7 @@ Walker.visit(D); } }; -} +} // end anonymous namespace #define REGISTER_CHECKER(name) \ void ento::register##name(CheckerManager &mgr) { \ @@ -752,4 +747,3 @@ REGISTER_CHECKER(InstanceVariableInvalidation) REGISTER_CHECKER(MissingInvalidationMethod) - Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp @@ -79,7 +79,6 @@ C.addTransition( State->set(ArraySym, SizeV.castAs())); - return; } void ObjCContainersChecker::checkPostStmt(const CallExpr *CE, @@ -156,10 +155,7 @@ const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind) const { - for (InvalidatedSymbols::const_iterator I = Escaped.begin(), - E = Escaped.end(); - I != E; ++I) { - SymbolRef Sym = *I; + for (const auto &Sym : Escaped) { // When a symbol for a mutable array escapes, we can't reason precisely // about its size any more -- so remove it from the map. // Note that we aren't notified here when a CFMutableArrayRef escapes as a @@ -169,6 +165,7 @@ } return State; } + /// Register checker. void ento::registerObjCContainersChecker(CheckerManager &mgr) { mgr.registerChecker(); Index: cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp @@ -76,7 +76,6 @@ report->addRange(SizeE->getSourceRange()); bugreporter::trackNullOrUndefValue(N, SizeE, *report); C.emitReport(std::move(report)); - return; } void VLASizeChecker::checkPreStmt(const DeclStmt *DS, CheckerContext &C) const { Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -379,7 +379,6 @@ } LCtx = LCtx->getParent(); } - } // The GDM component containing the dynamic dispatch bifurcation info. When @@ -393,7 +392,8 @@ DynamicDispatchModeInlined = 1, DynamicDispatchModeConservative }; -} +} // end anonymous namespace + REGISTER_TRAIT_WITH_PROGRAMSTATE(DynamicDispatchBifurcationMap, CLANG_ENTO_PROGRAMSTATE_MAP(const MemRegion *, unsigned)) @@ -426,7 +426,6 @@ currBldrCtx->getBlock(), currStmtIdx); - CallEnter Loc(CallE, CalleeSFC, CurLC); // Construct a new state which contains the mapping from actual to @@ -763,7 +762,6 @@ if (!Opts.mayInlineCXXSharedPtrDtor()) if (isCXXSharedPtrDtor(FD)) return false; - } } @@ -973,13 +971,10 @@ conservativeEvalCall(Call, Bldr, Pred, NoIState); NumOfDynamicDispatchPathSplits++; - return; } - void ExprEngine::VisitReturnStmt(const ReturnStmt *RS, ExplodedNode *Pred, ExplodedNodeSet &Dst) { - ExplodedNodeSet dstPreVisit; getCheckerManager().runCheckersForPreStmt(dstPreVisit, Pred, RS, *this); Index: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -35,7 +35,6 @@ template RegionTy* MemRegionManager::getRegion(const A1 a1) { - const typename MemRegionManagerTrait::SuperRegionTy *superRegion = MemRegionManagerTrait::getSuperRegion(*this, a1); @@ -74,7 +73,6 @@ template RegionTy* MemRegionManager::getRegion(const A1 a1, const A2 a2) { - const typename MemRegionManagerTrait::SuperRegionTy *superRegion = MemRegionManagerTrait::getSuperRegion(*this, a1, a2); @@ -96,7 +94,6 @@ template RegionTy* MemRegionManager::getSubRegion(const A1 a1, const A2 a2, const MemRegion *superRegion) { - llvm::FoldingSetNodeID ID; RegionTy::ProfileRegion(ID, a1, a2, superRegion); void *InsertPos; @@ -115,7 +112,6 @@ template RegionTy* MemRegionManager::getSubRegion(const A1 a1, const A2 a2, const A3 a3, const MemRegion *superRegion) { - llvm::FoldingSetNodeID ID; RegionTy::ProfileRegion(ID, a1, a2, a3, superRegion); void *InsertPos; @@ -582,12 +578,10 @@ os << "'"; printPrettyAsExpr(os); os << "'"; - return; } void MemRegion::printPrettyAsExpr(raw_ostream &os) const { llvm_unreachable("This region cannot be printed pretty."); - return; } bool VarRegion::canPrintPrettyAsExpr() const { @@ -628,7 +622,6 @@ } else { os << "field " << "\'" << getDecl()->getName() << "'"; } - return; } bool CXXBaseObjectRegion::canPrintPrettyAsExpr() const { @@ -892,7 +885,6 @@ const CompoundLiteralRegion* MemRegionManager::getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC) { - const MemRegion *sReg = nullptr; if (CL->isFileScope()) @@ -910,7 +902,6 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx, const MemRegion* superRegion, ASTContext &Ctx){ - QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType(); llvm::FoldingSetNodeID ID; Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -61,7 +61,6 @@ PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {} PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {} - void PathPieces::flattenTo(PathPieces &Primary, PathPieces &Current, bool ShouldFlattenMacros) const { for (PathPieces::const_iterator I = begin(), E = end(); I != E; ++I) { @@ -102,7 +101,6 @@ } } - PathDiagnostic::~PathDiagnostic() {} PathDiagnostic::PathDiagnostic(StringRef CheckName, const Decl *declWithIssue, @@ -278,6 +276,7 @@ } static Optional comparePath(const PathPieces &X, const PathPieces &Y); + static Optional compareControlFlow(const PathDiagnosticControlFlowPiece &X, const PathDiagnosticControlFlowPiece &Y) { @@ -505,7 +504,6 @@ // S might be a temporary statement that does not have a location in the // source code, so find an enclosing statement and use its location. if (!L.isValid()) { - AnalysisDeclContext *ADC; if (LAC.is()) ADC = LAC.get()->getAnalysisDeclContext(); @@ -578,22 +576,20 @@ llvm_unreachable("Unknown CFGElement kind"); } - PathDiagnosticLocation - PathDiagnosticLocation::createBegin(const Decl *D, - const SourceManager &SM) { +PathDiagnosticLocation::createBegin(const Decl *D, + const SourceManager &SM) { return PathDiagnosticLocation(D->getLocStart(), SM, SingleLocK); } PathDiagnosticLocation - PathDiagnosticLocation::createBegin(const Stmt *S, - const SourceManager &SM, - LocationOrAnalysisDeclContext LAC) { +PathDiagnosticLocation::createBegin(const Stmt *S, + const SourceManager &SM, + LocationOrAnalysisDeclContext LAC) { return PathDiagnosticLocation(getValidSourceLocation(S, LAC), SM, SingleLocK); } - PathDiagnosticLocation PathDiagnosticLocation::createEnd(const Stmt *S, const SourceManager &SM, @@ -605,13 +601,13 @@ } PathDiagnosticLocation - PathDiagnosticLocation::createOperatorLoc(const BinaryOperator *BO, - const SourceManager &SM) { +PathDiagnosticLocation::createOperatorLoc(const BinaryOperator *BO, + const SourceManager &SM) { return PathDiagnosticLocation(BO->getOperatorLoc(), SM, SingleLocK); } PathDiagnosticLocation - PathDiagnosticLocation::createConditionalColonLoc( +PathDiagnosticLocation::createConditionalColonLoc( const ConditionalOperator *CO, const SourceManager &SM) { return PathDiagnosticLocation(CO->getColonLoc(), SM, SingleLocK); @@ -619,28 +615,28 @@ PathDiagnosticLocation - PathDiagnosticLocation::createMemberLoc(const MemberExpr *ME, - const SourceManager &SM) { +PathDiagnosticLocation::createMemberLoc(const MemberExpr *ME, + const SourceManager &SM) { return PathDiagnosticLocation(ME->getMemberLoc(), SM, SingleLocK); } PathDiagnosticLocation - PathDiagnosticLocation::createBeginBrace(const CompoundStmt *CS, - const SourceManager &SM) { +PathDiagnosticLocation::createBeginBrace(const CompoundStmt *CS, + const SourceManager &SM) { SourceLocation L = CS->getLBracLoc(); return PathDiagnosticLocation(L, SM, SingleLocK); } PathDiagnosticLocation - PathDiagnosticLocation::createEndBrace(const CompoundStmt *CS, - const SourceManager &SM) { +PathDiagnosticLocation::createEndBrace(const CompoundStmt *CS, + const SourceManager &SM) { SourceLocation L = CS->getRBracLoc(); return PathDiagnosticLocation(L, SM, SingleLocK); } PathDiagnosticLocation - PathDiagnosticLocation::createDeclBegin(const LocationContext *LC, - const SourceManager &SM) { +PathDiagnosticLocation::createDeclBegin(const LocationContext *LC, + const SourceManager &SM) { // FIXME: Should handle CXXTryStmt if analyser starts supporting C++. if (const CompoundStmt *CS = dyn_cast_or_null(LC->getDecl()->getBody())) @@ -653,16 +649,15 @@ } PathDiagnosticLocation - PathDiagnosticLocation::createDeclEnd(const LocationContext *LC, - const SourceManager &SM) { +PathDiagnosticLocation::createDeclEnd(const LocationContext *LC, + const SourceManager &SM) { SourceLocation L = LC->getDecl()->getBodyRBrace(); return PathDiagnosticLocation(L, SM, SingleLocK); } PathDiagnosticLocation - PathDiagnosticLocation::create(const ProgramPoint& P, - const SourceManager &SMng) { - +PathDiagnosticLocation::create(const ProgramPoint& P, + const SourceManager &SMng) { const Stmt* S = nullptr; if (Optional BE = P.getAs()) { const CFGBlock *BSrc = BE->getSrc(); @@ -1062,7 +1057,6 @@ ID.AddInteger(Range.getBegin().getRawEncoding()); ID.AddInteger(Range.getEnd().getRawEncoding()); ID.AddInteger(Loc.getRawEncoding()); - return; } void PathDiagnosticPiece::Profile(llvm::FoldingSetNodeID &ID) const { Index: cfe/trunk/tools/libclang/CXSourceLocation.cpp =================================================================== --- cfe/trunk/tools/libclang/CXSourceLocation.cpp +++ cfe/trunk/tools/libclang/CXSourceLocation.cpp @@ -190,7 +190,6 @@ *column = 0; if (offset) *offset = 0; - return; } static void createNullLocation(CXString *filename, unsigned *line, @@ -203,7 +202,6 @@ *column = 0; if (offset) *offset = 0; - return; } extern "C" { @@ -235,7 +233,6 @@ unsigned *line, unsigned *column, unsigned *offset) { - if (!isASTUnitSourceLocation(location)) { CXLoadedDiagnostic::decodeLocation(location, file, line, column, offset); return; @@ -276,7 +273,6 @@ CXString *filename, unsigned *line, unsigned *column) { - if (!isASTUnitSourceLocation(location)) { // Other SourceLocation implementations do not support presumed locations // at this time. @@ -318,7 +314,6 @@ unsigned *line, unsigned *column, unsigned *offset) { - if (!isASTUnitSourceLocation(location)) { CXLoadedDiagnostic::decodeLocation(location, file, line, column, offset); @@ -356,7 +351,6 @@ unsigned *line, unsigned *column, unsigned *offset) { - if (!isASTUnitSourceLocation(location)) { CXLoadedDiagnostic::decodeLocation(location, file, line, column, offset);