diff --git a/include/Jit/utility.h b/include/Jit/utility.h index 158532c297c..30f77524399 100644 --- a/include/Jit/utility.h +++ b/include/Jit/utility.h @@ -28,11 +28,11 @@ #include "llvm/Config/llvm-config.h" // The MethodID.NumArgs field may hold either of 2 values: -// EMPTY => the input string was all-blank, or empty. -// ANYARGS => the pattern did not specify any constraint on the number of +// Empty => the input string was all-blank, or empty. +// AnyArgs => the pattern did not specify any constraint on the number of // arguments. Eg: "foo" as opposed to "foo()", "foo(3)", etc -enum MethodIDState { EMPTY = -7, ANYARGS = -1 }; +enum MethodIDState { Empty = -7, AnyArgs = -1 }; /// \brief MethodID struct represents a Method Signature. /// @@ -45,45 +45,45 @@ class MethodID { std::unique_ptr ClassName; /// Method Name std::unique_ptr MethodName; - /// Number of method arguments. MethodIDState::ANYARGS => not specified + /// Number of method arguments. MethodIDState::AnyArgs => not specified int NumArgs; /// Default constructor. MethodID() : ClassName(nullptr), MethodName(nullptr), - NumArgs(MethodIDState::ANYARGS) {} + NumArgs(MethodIDState::AnyArgs) {} /// Copy constructor. - MethodID(const MethodID &other) { - if (other.ClassName) { - ClassName = llvm::make_unique(*other.ClassName); + MethodID(const MethodID &Other) { + if (Other.ClassName) { + ClassName = llvm::make_unique(*Other.ClassName); } else { - ClassName == nullptr; + ClassName = nullptr; } - if (other.MethodName) { - MethodName = llvm::make_unique(*other.MethodName); + if (Other.MethodName) { + MethodName = llvm::make_unique(*Other.MethodName); } else { MethodName = nullptr; } - this->NumArgs = other.NumArgs; + this->NumArgs = Other.NumArgs; } /// Copy assignment operator. - MethodID &operator=(const MethodID &other) { - if (this == &other) + MethodID &operator=(const MethodID &Other) { + if (this == &Other) return *this; - if (other.ClassName) { - ClassName = llvm::make_unique(*other.ClassName); + if (Other.ClassName) { + ClassName = llvm::make_unique(*Other.ClassName); } else { ClassName = nullptr; } - if (other.MethodName) { - MethodName = llvm::make_unique(*other.MethodName); + if (Other.MethodName) { + MethodName = llvm::make_unique(*Other.MethodName); } else { MethodName = nullptr; } - NumArgs = other.NumArgs; + NumArgs = Other.NumArgs; return *this; } @@ -145,7 +145,7 @@ class MethodSet { /// \return true if Method is contained in Set. bool contains(const char *MethodName, const char *ClassName, - PCCOR_SIGNATURE sig); + PCCOR_SIGNATURE Sig); /// Initialize a new MethodSet - once only. void init(std::unique_ptr ConfigValue); @@ -170,7 +170,7 @@ class MethodSet { class Convert { public: /// Convert a UTF-16 string to a UTF-8 string. - static std::unique_ptr utf16ToUtf8(const char16_t *wideStr); + static std::unique_ptr utf16ToUtf8(const char16_t *WideStr); }; #endif // UTILITY_H diff --git a/include/Reader/abi.h b/include/Reader/abi.h index 16de38561a1..6833fa325ab 100644 --- a/include/Reader/abi.h +++ b/include/Reader/abi.h @@ -168,6 +168,9 @@ class ABIInfo { ABIType ResultType, llvm::ArrayRef ArgTypes, ABIArgInfo &ResultInfo, std::vector &ArgInfos) const = 0; + + /// \brief Virtual Destructor + virtual ~ABIInfo() = default; }; #endif diff --git a/include/Reader/readerir.h b/include/Reader/readerir.h index 9a3dc192bff..15216a5b455 100644 --- a/include/Reader/readerir.h +++ b/include/Reader/readerir.h @@ -813,7 +813,7 @@ class GenIR : public ReaderBase { /// \param Context Context to use for name generation.. /// \param Scope Scope to use for name generation. /// \returns Name for the given token, handle, context, and scope. - std::string GetNameForToken(mdToken Token, CORINFO_GENERIC_HANDLE Handle, + std::string getNameForToken(mdToken Token, CORINFO_GENERIC_HANDLE Handle, CORINFO_CONTEXT_HANDLE Context, CORINFO_MODULE_HANDLE Scope); @@ -1406,7 +1406,7 @@ class GenIR : public ReaderBase { /// /// \param PHI PHI instruction. /// \param NewOperand Operand to add to the PHI instruction. - void AddPHIOperand(llvm::PHINode *PHI, llvm::Value *NewOperand, + void addPHIOperand(llvm::PHINode *PHI, llvm::Value *NewOperand, llvm::BasicBlock *NewBlock); /// Change the type of a PHI instruction operand as a result of a stack merge. @@ -1415,7 +1415,7 @@ class GenIR : public ReaderBase { /// \param OperandBlock Basic block corresponding to the operand. /// \param NewTy New type of the operand. /// \returns Operand with the changed type. - llvm::Value *ChangePHIOperandType(llvm::Value *Operand, + llvm::Value *changePHIOperandType(llvm::Value *Operand, llvm::BasicBlock *OperandBlock, llvm::Type *NewTy); diff --git a/lib/Jit/LLILCJit.cpp b/lib/Jit/LLILCJit.cpp index b3db3b67ca6..3e64f2985f2 100644 --- a/lib/Jit/LLILCJit.cpp +++ b/lib/Jit/LLILCJit.cpp @@ -97,7 +97,7 @@ class ObjectLoadListener { /// /// \param LLVMRelocationType LLVM relocation type to translate from. /// \returns EE relocation type. - uint64_t TranslateRelocationType(uint64_t LLVMRelocationType); + uint64_t translateRelocationType(uint64_t LLVMRelocationType); private: LLILCJitContext *Context; @@ -582,7 +582,7 @@ void ObjectLoadListener::recordRelocations(const ObjectFile &Obj) { uint64_t Target = Context->NameToHandleMap[TargetName]; Context->JitInfo->recordRelocation(MM->getCodeSection() + Offset, (void *)Target, - TranslateRelocationType(RelType)); + translateRelocationType(RelType)); } ++I; } @@ -591,7 +591,7 @@ void ObjectLoadListener::recordRelocations(const ObjectFile &Obj) { } uint64_t -ObjectLoadListener::TranslateRelocationType(uint64_t LLVMRelocationType) { +ObjectLoadListener::translateRelocationType(uint64_t LLVMRelocationType) { switch (LLVMRelocationType) { case IMAGE_REL_AMD64_ABSOLUTE: return IMAGE_REL_BASED_ABSOLUTE; diff --git a/lib/Jit/utility.cpp b/lib/Jit/utility.cpp index ec6d2ec6ba6..41236b09372 100644 --- a/lib/Jit/utility.cpp +++ b/lib/Jit/utility.cpp @@ -17,51 +17,51 @@ int MethodID::parseArgs(const string &S, size_t &I) { I = S.find_first_of(")", I); if (I == string::npos) - return MethodIDState::ANYARGS; + return MethodIDState::AnyArgs; - string num = string(S, Start, I - Start); - int NArgs = atoi(num.c_str()); + string Num = string(S, Start, I - Start); + int NArgs = atoi(Num.c_str()); ++I; // skip ) return NArgs; } unique_ptr MethodID::parse(const string &S, size_t &I) { - MethodID MID; + MethodID MId; size_t SLen = S.length(); - string token = MID.scan(S, I); + string Token = MId.scan(S, I); - if (token == "") // off the end of S + if (Token == "") // off the end of S return nullptr; - if (token == "*") { - MID.ClassName = llvm::make_unique(token); - MID.MethodName = nullptr; + if (Token == "*") { + MId.ClassName = llvm::make_unique(Token); + MId.MethodName = nullptr; if (I >= SLen || S[I] == ' ') { - MID.NumArgs = MethodIDState::ANYARGS; + MId.NumArgs = MethodIDState::AnyArgs; } - return llvm::make_unique(MID); + return llvm::make_unique(MId); return nullptr; } if (S[I] == ':') { // C:M | C:M(A) - MID.ClassName = llvm::make_unique(token); - token = MID.scan(S, ++I); // M | M(A) + MId.ClassName = llvm::make_unique(Token); + Token = MId.scan(S, ++I); // M | M(A) } - MID.MethodName = llvm::make_unique(token); + MId.MethodName = llvm::make_unique(Token); if (I >= SLen || S[I] == ' ') { - MID.NumArgs = MethodIDState::ANYARGS; - return llvm::make_unique(MID); + MId.NumArgs = MethodIDState::AnyArgs; + return llvm::make_unique(MId); return nullptr; } if (S[I] != '(') // illegal return nullptr; - MID.NumArgs = MID.parseArgs(S, I); - return llvm::make_unique(MID); + MId.NumArgs = MId.parseArgs(S, I); + return llvm::make_unique(MId); return nullptr; } @@ -90,22 +90,22 @@ void MethodSet::init(unique_ptr ConfigValue) { void MethodSet::insert(unique_ptr Ups) { size_t I = 0; - std::list *MIDL = new std::list(); + std::list *MIdList = new std::list(); string S = *Ups; - auto MID = MethodID::parse(S, I); - while (MID) { - MIDL->push_back(*MID); - MID = MethodID::parse(S, I); + auto MId = MethodID::parse(S, I); + while (MId) { + MIdList->push_back(*MId); + MId = MethodID::parse(S, I); } // This write should be atomic, delete if we're not the first. llvm::sys::cas_flag F = llvm::sys::CompareAndSwap( (llvm::sys::cas_flag *)&(this->Initialized), 0x1, 0x0); if (F != 0x0) { - delete MIDL; + delete MIdList; } else { - this->MethodIDList = MIDL; + this->MethodIDList = MIdList; } } @@ -114,7 +114,7 @@ bool MethodSet::contains(const char *MethodName, const char *ClassName, assert(this->isInitialized()); - int NumArgs = MethodIDState::ANYARGS; // assume no signature supplied + int NumArgs = MethodIDState::AnyArgs; // assume no signature supplied if (PCSig) { PCSig++; // skip calling convention @@ -124,28 +124,28 @@ bool MethodSet::contains(const char *MethodName, const char *ClassName, string StrClassName = ClassName ? ClassName : ""; string StrMethodName = MethodName ? MethodName : ""; - auto begin = this->MethodIDList->begin(); - auto end = this->MethodIDList->end(); + auto Begin = this->MethodIDList->begin(); + auto End = this->MethodIDList->end(); - for (auto p = begin; p != end; ++p) { // p => "pattern" + for (auto P = Begin; P != End; ++P) { // P => "pattern" // Check for "*", the common case, first - if (p->ClassName && *p->ClassName == "*") + if (P->ClassName && *P->ClassName == "*") return true; // Check for mis-match on NumArgs - if (p->NumArgs != MethodIDState::ANYARGS && p->NumArgs != NumArgs) + if (P->NumArgs != MethodIDState::AnyArgs && P->NumArgs != NumArgs) continue; // Check for mis-match on MethodName - if (p->MethodName && (*p->MethodName != StrMethodName)) + if (P->MethodName && (*P->MethodName != StrMethodName)) continue; // Check for match on ClassName (we already match NumArgs and MethodName) - if (!p->ClassName) // no ClassName + if (!P->ClassName) // no ClassName return true; - if (*p->ClassName == StrClassName) + if (*P->ClassName == StrClassName) return true; } diff --git a/lib/Reader/reader.cpp b/lib/Reader/reader.cpp index 3f3f1c30880..e5f206d7fac 100644 --- a/lib/Reader/reader.cpp +++ b/lib/Reader/reader.cpp @@ -2800,7 +2800,7 @@ EHRegion *getFinallyRegion(EHRegion *TryRegion) { #define CHECKTARGET(TargetOffset, BufSize) \ { \ - if (TargetOffset < 0 || TargetOffset >= BufSize) \ + if ((TargetOffset) < 0 || (TargetOffset) >= (BufSize)) \ ReaderBase::verGlobalError(MVER_E_BAD_BRANCH); \ } @@ -8000,9 +8000,9 @@ void ReaderBase::msilToIR(void) { } // Process the nodes in MSIL offset order. - std::list::iterator it = FlowGraphMSILOffsetOrder.begin(); - while (it != FlowGraphMSILOffsetOrder.end()) { - FlowGraphNode *CurrentNode = *it; + std::list::iterator It = FlowGraphMSILOffsetOrder.begin(); + while (It != FlowGraphMSILOffsetOrder.end()) { + FlowGraphNode *CurrentNode = *It; readBytesForFlowGraphNode(CurrentNode, IsImportOnly); #ifndef CC_PEVERIFY @@ -8029,15 +8029,15 @@ void ReaderBase::msilToIR(void) { // The two checks above ensure that it's safe to insert Successor after // CurrentNode even if that breaks MSIL offset order. - ++it; - FlowGraphMSILOffsetOrder.insert(it, Successor); + ++It; + FlowGraphMSILOffsetOrder.insert(It, Successor); // Point the iterator back to CurrentNode. - --it; - --it; + --It; + --It; fgNodeSetVisited(Successor, true); } } - ++it; + ++It; } // global verification dataflow diff --git a/lib/Reader/readerir.cpp b/lib/Reader/readerir.cpp index e2eb0d5e271..d37734a101c 100644 --- a/lib/Reader/readerir.cpp +++ b/lib/Reader/readerir.cpp @@ -58,10 +58,10 @@ IRNode *GenStack::pop() { LLILCJit::fatal(CORJIT_BADCODE); } - IRNode *result = Stack.back(); + IRNode *Result = Stack.back(); Stack.pop_back(); - return result; + return Result; } void GenStack::assertEmpty() { ASSERT(empty()); } @@ -493,8 +493,8 @@ void GenIR::readerPostPass(bool IsImportOnly) { // managed pointers yet. So, check if this function deals with such values // and fail early. (Issue #33) - for (const Argument &arg : Function->args()) { - if (isManagedAggregateType(arg.getType())) { + for (const Argument &Arg : Function->args()) { + if (isManagedAggregateType(Arg.getType())) { throw NotYetImplementedException( "NYI: Precice GC for Managed-Aggregate values"); } @@ -1340,13 +1340,13 @@ GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool GetAggregateFields, // Now that this aggregate's fields are filled in, go back // and fill in the details for those aggregates we deferred // handling earlier. - std::list::iterator it = + std::list::iterator It = TheDeferredDetailAggregates.begin(); - while (it != TheDeferredDetailAggregates.end()) { - CORINFO_CLASS_HANDLE DeferredClassHandle = *it; + while (It != TheDeferredDetailAggregates.end()) { + CORINFO_CLASS_HANDLE DeferredClassHandle = *It; getClassTypeWorker(DeferredClassHandle, GetAggregateFields, DeferredDetailAggregates); - ++it; + ++It; } } else { if (!GetAggregateFields) { @@ -2412,7 +2412,7 @@ bool GenIR::isArrayType(llvm::Type *ArrayTy, llvm::Type *ElementTy) { return false; } ArrayType *ElementsArrayType = cast(ElementsArrayFieldType); - if (!ElementsArrayType->getArrayNumElements() == 0) { + if (ElementsArrayType->getArrayNumElements() != 0) { return false; } llvm::Type *ActualElementTy = ElementsArrayType->getArrayElementType(); @@ -2437,9 +2437,9 @@ IRNode *GenIR::ensureIsArray(IRNode *Array, llvm::Type *ElementTy) { } PointerType *GenIR::getArrayOfElementType(llvm::Type *ElementTy) { - auto it = ElementToArrayTypeMap.find(ElementTy); - if (it != ElementToArrayTypeMap.end()) { - return it->second; + auto It = ElementToArrayTypeMap.find(ElementTy); + if (It != ElementToArrayTypeMap.end()) { + return It->second; } PointerType *Array = createArrayOfElementType(ElementTy); ElementToArrayTypeMap[ElementTy] = Array; @@ -4686,10 +4686,10 @@ IRNode *GenIR::callRuntimeHandleHelper(CorInfoHelpFunc Helper, IRNode *Arg1, // return x; BasicBlock *CurrentBlock = LLVMBuilder->GetInsertBlock(); BasicBlock *CallBlock = HelperCall->getParent(); - PHINode *PHI = mergeConditionalResults(CurrentBlock, NullCheckArg, SaveBlock, + PHINode *Phi = mergeConditionalResults(CurrentBlock, NullCheckArg, SaveBlock, HelperCall.getInstruction(), CallBlock, "RuntimeHandle"); - return (IRNode *)PHI; + return (IRNode *)Phi; } IRNode *GenIR::convertHandle(IRNode *GetTokenNumericNode, @@ -6060,7 +6060,7 @@ IRNode *GenIR::handleToIRNode(mdToken Token, void *EmbHandle, void *RealHandle, if (IsRelocatable) { std::string HandleName = - GetNameForToken(Token, (CORINFO_GENERIC_HANDLE)LookupHandle, + getNameForToken(Token, (CORINFO_GENERIC_HANDLE)LookupHandle, getCurrentContext(), getCurrentModuleHandle()); GlobalVariable *GlobalVar = getGlobalVariable( LookupHandle, ValueHandle, HandleTy, HandleName, IsReadOnly); @@ -6082,7 +6082,7 @@ IRNode *GenIR::handleToIRNode(mdToken Token, void *EmbHandle, void *RealHandle, return (IRNode *)HandleValue; } -std::string GenIR::GetNameForToken(mdToken Token, CORINFO_GENERIC_HANDLE Handle, +std::string GenIR::getNameForToken(mdToken Token, CORINFO_GENERIC_HANDLE Handle, CORINFO_CONTEXT_HANDLE Context, CORINFO_MODULE_HANDLE Scope) { std::string Storage; @@ -6095,19 +6095,19 @@ std::string GenIR::GetNameForToken(mdToken Token, CORINFO_GENERIC_HANDLE Handle, (CorInfoHelpFunc)RidFromToken(Token)) << "::JitHelper"; break; case mdtVarArgsHandle: - OS << GetNameForToken(TokenFromRid(RidFromToken(Token), mdtMemberRef), + OS << getNameForToken(TokenFromRid(RidFromToken(Token), mdtMemberRef), Handle, Context, Scope) << "::VarArgsHandle"; break; case mdtVarArgsMDHandle: - OS << GetNameForToken(TokenFromRid(RidFromToken(Token), mdtMethodDef), + OS << getNameForToken(TokenFromRid(RidFromToken(Token), mdtMethodDef), Handle, Context, Scope) << "::VarArgsHandle"; break; case mdtVarArgsMSHandle: - OS << GetNameForToken(TokenFromRid(RidFromToken(Token), mdtMethodSpec), + OS << getNameForToken(TokenFromRid(RidFromToken(Token), mdtMethodSpec), Handle, Context, Scope) << "::VarArgsHandle"; break; case mdtVarArgsSigHandle: - OS << GetNameForToken(TokenFromRid(RidFromToken(Token), mdtSignature), + OS << getNameForToken(TokenFromRid(RidFromToken(Token), mdtSignature), Handle, Context, Scope) << "::VarArgsHandle"; break; case mdtInterfaceOffset: @@ -6372,14 +6372,14 @@ PHINode *GenIR::mergeConditionalResults(BasicBlock *JoinBlock, Value *Arg1, BasicBlock *Block1, Value *Arg2, BasicBlock *Block2, const Twine &NameStr) { - PHINode *PHI = createPHINode(JoinBlock, Arg1->getType(), 2, NameStr); - PHI->addIncoming(Arg1, Block1); - PHI->addIncoming(Arg2, Block2); + PHINode *Phi = createPHINode(JoinBlock, Arg1->getType(), 2, NameStr); + Phi->addIncoming(Arg1, Block1); + Phi->addIncoming(Arg2, Block2); if (doesValueRepresentStruct(Arg1)) { assert(doesValueRepresentStruct(Arg2)); - setValueRepresentsStruct(PHI); + setValueRepresentsStruct(Phi); } - return PHI; + return Phi; } // Handle case of an indirection from CORINFO_RUNTIME_LOOKUP where @@ -7159,7 +7159,7 @@ void GenIR::maintainOperandStack(FlowGraphNode *CurrentBlock) { } Instruction *CurrentInst = SuccessorBlock->begin(); - PHINode *PHI = nullptr; + PHINode *Phi = nullptr; for (IRNode *Current : *ReaderOperandStack) { Value *CurrentValue = (Value *)Current; if (CreatePHIs) { @@ -7167,9 +7167,9 @@ void GenIR::maintainOperandStack(FlowGraphNode *CurrentBlock) { // hint for the number of PHI sources. // TODO: Could be nice to have actual pred. count here instead, but // there's no simple way of fetching that, AFAICT. - PHI = createPHINode(SuccessorBlock, CurrentValue->getType(), 2, ""); + Phi = createPHINode(SuccessorBlock, CurrentValue->getType(), 2, ""); if (doesValueRepresentStruct(CurrentValue)) { - setValueRepresentsStruct(PHI); + setValueRepresentsStruct(Phi); } // Preemptively add all predecessors to the PHI node to ensure @@ -7177,19 +7177,19 @@ void GenIR::maintainOperandStack(FlowGraphNode *CurrentBlock) { FlowGraphEdgeList *PredecessorList = fgNodeGetPredecessorListActual(SuccessorBlock); while (PredecessorList != nullptr) { - PHI->addIncoming(UndefValue::get(CurrentValue->getType()), + Phi->addIncoming(UndefValue::get(CurrentValue->getType()), fgEdgeListGetSource(PredecessorList)); PredecessorList = fgEdgeListGetNextPredecessorActual(PredecessorList); } } else { // PHI instructions should have been inserted already - PHI = cast(CurrentInst); + Phi = cast(CurrentInst); CurrentInst = CurrentInst->getNextNode(); } - AddPHIOperand(PHI, CurrentValue, (BasicBlock *)CurrentBlock); + addPHIOperand(Phi, CurrentValue, (BasicBlock *)CurrentBlock); if (CreatePHIs) { - SuccessorStack->push((IRNode *)PHI); + SuccessorStack->push((IRNode *)Phi); } } @@ -7203,13 +7203,13 @@ void GenIR::maintainOperandStack(FlowGraphNode *CurrentBlock) { clearStack(); } -void GenIR::AddPHIOperand(PHINode *PHI, Value *NewOperand, +void GenIR::addPHIOperand(PHINode *Phi, Value *NewOperand, BasicBlock *NewBlock) { - Type *PHITy = PHI->getType(); + Type *PHITy = Phi->getType(); Type *NewOperandTy = NewOperand->getType(); if (PHITy != NewOperandTy) { - bool IsStructPHITy = doesValueRepresentStruct(PHI); + bool IsStructPHITy = doesValueRepresentStruct(Phi); bool IsStructNewOperandTy = doesValueRepresentStruct(NewOperand); Type *NewPHITy = getStackMergeType(PHITy, NewOperandTy, IsStructPHITy, IsStructNewOperandTy); @@ -7217,31 +7217,31 @@ void GenIR::AddPHIOperand(PHINode *PHI, Value *NewOperand, if (NewPHITy != PHITy) { // Change the type of the PHI instruction and the types of all of its // operands. - PHI->mutateType(NewPHITy); - for (unsigned i = 0; i < PHI->getNumOperands(); ++i) { - Value *Operand = PHI->getIncomingValue(i); + Phi->mutateType(NewPHITy); + for (unsigned I = 0; I < Phi->getNumOperands(); ++I) { + Value *Operand = Phi->getIncomingValue(I); if (!isa(Operand)) { - BasicBlock *OperandBlock = PHI->getIncomingBlock(i); - Operand = ChangePHIOperandType(Operand, OperandBlock, NewPHITy); - PHI->setIncomingValue(i, Operand); + BasicBlock *OperandBlock = Phi->getIncomingBlock(I); + Operand = changePHIOperandType(Operand, OperandBlock, NewPHITy); + Phi->setIncomingValue(I, Operand); } } } if (NewPHITy != NewOperandTy) { // Change the type of the new PHI operand. - NewOperand = ChangePHIOperandType(NewOperand, NewBlock, NewPHITy); + NewOperand = changePHIOperandType(NewOperand, NewBlock, NewPHITy); } LLVMBuilder->restoreIP(SavedInsertPoint); } - int BlockIndex = PHI->getBasicBlockIndex(NewBlock); + int BlockIndex = Phi->getBasicBlockIndex(NewBlock); if (BlockIndex >= 0) - PHI->setIncomingValue(BlockIndex, NewOperand); + Phi->setIncomingValue(BlockIndex, NewOperand); else - PHI->addIncoming(NewOperand, NewBlock); + Phi->addIncoming(NewOperand, NewBlock); } -Value *GenIR::ChangePHIOperandType(Value *Operand, BasicBlock *OperandBlock, +Value *GenIR::changePHIOperandType(Value *Operand, BasicBlock *OperandBlock, Type *NewTy) { LLVMBuilder->SetInsertPoint(OperandBlock->getTerminator()); if (NewTy->isIntegerTy()) { diff --git a/utils/ccformat.py b/utils/ccformat.py index 7c71a92a73f..0b9a9ec65fe 100755 --- a/utils/ccformat.py +++ b/utils/ccformat.py @@ -13,13 +13,7 @@ def expandPath(path): return os.path.abspath(os.path.expanduser(path)) def runTidy(args): - if args.llilc_source == None: - print >> sys.stderr, "Please specify --llilc-source or set the " \ - "LLILC_SOURCE environment variable." - return 1 - tidyFix = "-fix" if args.fix else "" - osInc = "" osIncList = [] @@ -35,14 +29,21 @@ def runTidy(args): if args.llvm_source is None: print >> sys.stderr, "Please specify --llvm-source or set the " \ - "LLVM_SOURCE environment variable." + "LLVMSOURCE environment variable." return 1 if args.llvm_build is None: print >> sys.stderr, "Please specify --llvm-build or set the " \ - "LLVM_BUILD environment variable." + "LLVMBUILD environment variable." + return 1 + + if args.coreclr_build is None: + print >> sys.stderr, "Please specify --coreclr-build or set the " \ + "CORECLRBUILD environment variable." return 1 + coreclrbuild = expandPath(args.coreclr_build) + llvmbuild = expandPath(args.llvm_build) llilcSrc = expandPath(args.llilc_source) llilcBuild = "" if args.llilc_build != None: @@ -65,12 +66,17 @@ def runTidy(args): os.path.join(expandPath(args.llvm_source), "include"), os.path.join(llilcInc, "clr"), os.path.join(llilcInc, "Driver"), + os.path.join(llilcInc, "GcInfo"), os.path.join(llilcInc, "Jit"), - os.path.join(llilcInc, "Reader"), os.path.join(llilcInc, "Pal"), + os.path.join(llilcInc, "Reader"), os.path.join(llilcBuild, "lib", "Reader"), os.path.join(llilcBuild, "include"), - os.path.join(expandPath(args.llvm_build), "include") + os.path.join(llvmbuild, "include") + ] + clrincludes = [ + os.path.join(coreclrbuild, "inc"), + os.path.join(coreclrbuild, "gcinfo") ] defines = [ "_DEBUG", @@ -87,11 +93,21 @@ def runTidy(args): "LLILCJit_EXPORTS", "_WINDLL", "_MBCS", - "NOMINMAX" + "NOMINMAX", + "STANDALONE_BUILD", + "LLILC_TARGET_TRIPLE=\\\"\\\"" + ] + excludes = [ + # Contains utility functions used by the standalone build + # of CoreCLR's GcInfo encoder implementation + "GcInfoUtil.cpp", + # ABI code uses some variable names with underscores, + # by convention. + "abi.cpp" ] - clangArgs = " ".join(["--"] + flags + ["-I" + i for i in includes] \ + + ["-isystem" + i for i in clrincludes] \ + ["-isystem" + i for i in osIncList] \ + ["-D" + d for d in defines]) else: @@ -101,20 +117,30 @@ def runTidy(args): for dirname,subdir,files in os.walk(llilcSrc): for filename in files: if filename.endswith(".c") or filename.endswith(".cpp"): + if filename in excludes: + continue filepath = os.path.join(dirname, filename) - errorlevel = subprocess.call(" ".join([args.clang_tidy, tidyFix, + proc = subprocess.Popen(" ".join([args.clang_tidy, tidyFix, "-checks=" + args.checks, "-header-filter=\"" + llilcSrc + ".*(Reader)|(Jit)|(Pal)\"", - filepath, clangArgs]), shell=True) - if errorlevel == 1: - returncode = 1 - + filepath, clangArgs]), shell=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + output,error = proc.communicate() + + # Fail if there are any errors or warnings. + # error only contains a message about suppressed warnings + # output may contain errors/warnings about coding conventions + warnings = io.StringIO(output.decode('utf-8')).read() + if len(warnings) > 0: + sys.stdout.write(warnings) + returncode = -2 + return returncode def runFormat(args): formatFix = "-i" if args.fix else "" returncode = 0 - llilcSrc = expandPath(args.llilc_source) llilcSrc = expandPath(args.llilc_source) for dirname,subdir,files in os.walk(llilcSrc): @@ -174,6 +200,10 @@ def main(argv): help="path to LLVM sources. If not specified, defaults to the " \ "value of the LLVMSOURCE environment variable. Only used " \ "when a compile commands database has not been specified.") + parser.add_argument("--coreclr-build", metavar="PATH", + default=os.environ.get("CORECLRBUILD"), + help="path to CoreCLR build. Only used when a compile commands " \ + "database has not been specified.") parser.add_argument("--llilc-build", metavar="PATH", default=None if llvmBuild is None else \ os.path.join(llvmBuild, "tools", "llilc"), \ @@ -184,8 +214,8 @@ def main(argv): help="path to LLILC sources") parser.add_argument("--fix", action="store_true", default=False, help="fix failures when possible") - parser.add_argument("--tidy", action="store_true", default=False, - help="Run clang-tidy") + parser.add_argument("--untidy", action="store_true", default=False, + help="Don't run clang-tidy") parser.add_argument("--noformat", action="store_true", default=False, help="Don\'t run clang-format-diff") parser.add_argument("--checks", default="llvm*,misc*,microsoft*,"\ @@ -197,10 +227,10 @@ def main(argv): if unknown: print("Unknown argument(s): ", ", ".join(unknown)) - return -2 + return -3 returncode=0 - if args.tidy: + if not args.untidy: returncode = runTidy(args) if returncode != 0: return returncode