[dragonegg] r176016 - Format with clang-format.

Hi Daniel,

There's a few curious cases in here:

Author: baldrick
Date: Mon Feb 25 04:54:25 2013
New Revision: 176016

URL: http://llvm.org/viewvc/llvm-project?rev=176016&view=rev
Log:
Format with clang-format.

Modified:
    dragonegg/trunk/include/arm/dragonegg/Target.h
    dragonegg/trunk/include/dragonegg/ABI.h
    dragonegg/trunk/include/dragonegg/ADT/IntervalList.h
    dragonegg/trunk/include/dragonegg/Debug.h
    dragonegg/trunk/include/dragonegg/Internals.h
    dragonegg/trunk/include/dragonegg/TypeConversion.h
    dragonegg/trunk/include/x86/dragonegg/Target.h
    dragonegg/trunk/src/Aliasing.cpp
    dragonegg/trunk/src/Backend.cpp
    dragonegg/trunk/src/Cache.cpp
    dragonegg/trunk/src/ConstantConversion.cpp
    dragonegg/trunk/src/Convert.cpp
    dragonegg/trunk/src/Debug.cpp
    dragonegg/trunk/src/DefaultABI.cpp
    dragonegg/trunk/src/Trees.cpp
    dragonegg/trunk/src/TypeConversion.cpp
    dragonegg/trunk/src/arm/Target.cpp
    dragonegg/trunk/src/x86/Target.cpp

Modified: dragonegg/trunk/include/arm/dragonegg/Target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/arm/dragonegg/Target.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/arm/dragonegg/Target.h (original)
+++ dragonegg/trunk/include/arm/dragonegg/Target.h Mon Feb 25 04:54:25 2013
@@ -70,8 +70,8 @@ extern bool llvm_arm_aggregate_partially
#define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE, ISR, CC) \
   llvm_arm_aggregate_partially_passed_in_regs((E), (SE), (CC))

-extern Type *llvm_arm_aggr_type_for_struct_return(tree_node *type,
- CallingConv::ID CC);
+extern Type *
+llvm_arm_aggr_type_for_struct_return(tree_node *type, CallingConv::ID CC);

/* LLVM_AGGR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be
   returned as an aggregate, otherwise return NULL. */
@@ -263,21 +263,35 @@ extern bool llvm_arm_should_pass_or_retu
  * with function notes.
  */
#define LLVM_OVERRIDE_TARGET_ARCH() \
- (TARGET_THUMB ? \
- (arm_arch7 ? "thumbv7" : \
- (arm_arch_thumb2 ? "thumbv6t2" : \
- (arm_tune == cortexm0 ? "thumbv6m" : \
- (arm_arch6 ? "thumbv6" : \
- (arm_arch5e ? "thumbv5e" : \
- (arm_arch5 ? "thumbv5" : \
- (arm_arch4t ? "thumbv4t" : ""))))))) : \
- (arm_arch7 ? "armv7" : \
- (arm_arch_thumb2 ? "armv6t2" : \
- (arm_arch6 ? "armv6" : \
- (arm_arch5e ? "armv5e" : \
- (arm_arch5 ? "armv5" : \
- (arm_arch4t ? "armv4t" : \
- (arm_arch4 ? "armv4" : ""))))))))
+ (TARGET_THUMB \
+ ? (arm_arch7 \
+ ? "thumbv7" \
+ : (arm_arch_thumb2 \
+ ? "thumbv6t2" \
+ : (arm_tune == cortexm0 \
+ ? "thumbv6m" \
+ : (arm_arch6 \
+ ? "thumbv6" \
+ : (arm_arch5e \
+ ? "thumbv5e" \
+ : (arm_arch5 \
+ ? "thumbv5" \
+ : (arm_arch4t ? "thumbv4t" \
+ : ""))))))) \
+ : (arm_arch7 \
+ ? "armv7" \
+ : (arm_arch_thumb2 \
+ ? "armv6t2" \
+ : (arm_arch6 \
+ ? "armv6" \
+ : (arm_arch5e \
+ ? "armv5e" \
+ : (arm_arch5 \
+ ? "armv5" \
+ : (arm_arch4t \
+ ? "armv4t" \
+ : (arm_arch4 ? "armv4" \
+ : ""))))))))

#if 0
// Dragonegg should make flag_mkernel and flag_apple_kext option later on.
@@ -322,9 +336,10 @@ extern bool llvm_arm_should_pass_or_retu
    so use the incoming register name if it exists. Otherwise, use the default
    register names to match the backend. */
#define LLVM_GET_REG_NAME(REG_NAME, REG_NUM) \
- ((REG_NUM) == 10 ? "r10" : (REG_NUM) == 11 ? "r11" : (REG_NUM) == 12 ? \
- "r12" : (REG_NUM) >= FIRST_VFP_REGNUM && REG_NAME != 0 ? REG_NAME : \
- reg_names[REG_NUM])
+ ((REG_NUM) == 10 ? "r10" : (REG_NUM) == \
+ 11 ? "r11" : (REG_NUM) == \
+ 12 ? "r12" : (REG_NUM) >= FIRST_VFP_REGNUM && \
+ REG_NAME != 0 ? REG_NAME : reg_names[REG_NUM])

Probably fine, but not sure how I feel about splitting inside the
third subexpression to the conditional operator rather than splitting
out at a '?' or ':' boundary. I'm assuming the alternatives that split
at those spots would be worse due to line length issues.

/* Define a static enumeration of the NEON builtins to be used when
    converting to LLVM intrinsics. These names are derived from the

Modified: dragonegg/trunk/include/dragonegg/ABI.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/ABI.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/dragonegg/ABI.h (original)
+++ dragonegg/trunk/include/dragonegg/ABI.h Mon Feb 25 04:54:25 2013
@@ -143,8 +143,8 @@ extern bool isZeroSizedStructOrUnion(tre
// getLLVMScalarTypeForStructReturn - Return LLVM Type if TY can be
// returned as a scalar, otherwise return NULL. This is the default
// target independent implementation.
-inline Type *getLLVMScalarTypeForStructReturn(tree_node *type,
- unsigned *Offset) {
+inline Type *
+getLLVMScalarTypeForStructReturn(tree_node *type, unsigned *Offset) {
   Type *Ty = ConvertType(type);
   uint64_t Size = getDataLayout().getTypeAllocSize(Ty);
   *Offset = 0;

Modified: dragonegg/trunk/include/dragonegg/ADT/IntervalList.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/ADT/IntervalList.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/dragonegg/ADT/IntervalList.h (original)
+++ dragonegg/trunk/include/dragonegg/ADT/IntervalList.h Mon Feb 25 04:54:25 2013
@@ -61,8 +61,8 @@ template <class T, typename U, unsigned
     for (unsigned i = 0, e = (unsigned) Intervals.size(); i < e; ++i) {
       if (Intervals[i].getRange().empty())
         return false;
- if (i && Intervals[i].getRange().getFirst() <
- Intervals[i - 1].getRange().getLast())
+ if (i && Intervals[i].getRange().getFirst() < Intervals[i - 1]
+ .getRange().getLast())

This seems less than optimal - wouldn't it be better to split the
whole RHS of the '<'?

         return false;
     }
     return true;
@@ -106,10 +106,10 @@ void IntervalList<T, U, N>::AddInterval(
   }

   // Check for overlap with existing intervals.
- iterator Lo = std::lower_bound(Intervals.begin(), Intervals.end(), Interval,
- CmpFirst);
- iterator Hi = std::upper_bound(Intervals.begin(), Intervals.end(), Interval,
- CmpLast);
+ iterator Lo =
+ std::lower_bound(Intervals.begin(), Intervals.end(), Interval, CmpFirst);
+ iterator Hi =
+ std::upper_bound(Intervals.begin(), Intervals.end(), Interval, CmpLast);
   if (Lo < Hi) {
     // Intervals with index in [Lo, Hi) are those completely covered by the new
     // interval. Throw them away.

Modified: dragonegg/trunk/include/dragonegg/Debug.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Debug.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/dragonegg/Debug.h (original)
+++ dragonegg/trunk/include/dragonegg/Debug.h Mon Feb 25 04:54:25 2013
@@ -80,10 +80,10 @@ public:

   /// CreateCompileUnit - Create a new descriptor for the specified compile
   /// unit.
- void CreateCompileUnit(
- unsigned LangID, StringRef Filename, StringRef Directory,
- StringRef Producer, bool isMain = false, bool isOptimized = false,
- StringRef Flags = "", unsigned RunTimeVer = 0);
+ void CreateCompileUnit(unsigned LangID, StringRef Filename,
+ StringRef Directory, StringRef Producer,
+ bool isMain = false, bool isOptimized = false,
+ StringRef Flags = "", unsigned RunTimeVer = 0);

   /// CreateFile - Create a new descriptor for the specified file.
   DIFile CreateFile(StringRef Filename, StringRef Directory);
@@ -115,7 +115,7 @@ public:
       unsigned Tag, DIDescriptor Context, StringRef Name, DIFile F,
       unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits,
       uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom,
- DIArray Elements, unsigned RunTimeLang = 0, MDNode * ContainingType = 0);
+ DIArray Elements, unsigned RunTimeLang = 0, MDNode *ContainingType = 0);

   /// CreateTemporaryType - Create a temporary forward-declared type.
   DIType CreateTemporaryType();
@@ -131,12 +131,12 @@ public:
       StringRef LinkageName, DIFile F, unsigned LineNo, DIType Ty,
       bool isLocalToUnit, bool isDefinition, unsigned VK = 0,
       unsigned VIndex = 0, DIType ContainingType = DIType(), unsigned Flags = 0,
- bool isOptimized = false, Function * Fn = 0);
+ bool isOptimized = false, Function *Fn = 0);

   /// CreateSubprogramDefinition - Create new subprogram descriptor for the
   /// given declaration.
- DISubprogram CreateSubprogramDefinition(DISubprogram& SPDeclaration,
- unsigned LineNo, Function* Fn);
+ DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration,
+ unsigned LineNo, Function *Fn);

   /// CreateGlobalVariable - Create a new descriptor for the specified global.
   DIGlobalVariable CreateGlobalVariable(
@@ -180,12 +180,12 @@ public:
                             MDNode *OrigLoc = 0);

   /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
- Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
- BasicBlock *InsertAtEnd);
+ Instruction *
+ InsertDeclare(llvm::Value *Storage, DIVariable D, BasicBlock *InsertAtEnd);

   /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
- Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
- Instruction *InsertBefore);
+ Instruction *
+ InsertDeclare(llvm::Value *Storage, DIVariable D, Instruction *InsertBefore);

   /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
   Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,

Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Mon Feb 25 04:54:25 2013
@@ -146,8 +146,8 @@ bool isPaddingElement(tree_node *, unsig
/// that has no value specified. For example in C like languages such variables
/// are initialized to zero, while in Ada they hold an undefined value.
inline Constant *getDefaultValue(Type *Ty) {
- return flag_default_initialize_globals ? Constant::getNullValue(Ty) :
- UndefValue::get(Ty);
+ return flag_default_initialize_globals ? Constant::getNullValue(Ty)
+ : UndefValue::get(Ty);
}

/// isPassedByInvisibleReference - Return true if the specified type should be
@@ -323,10 +323,10 @@ public:

   /// CastToAnyType - Cast the specified value to the specified type regardless
   /// of the types involved. This is an inferred cast.
- Value *CastToAnyType(Value *Src, bool SrcIsSigned, Type *DstTy,
- bool DstIsSigned);
- Constant *CastToAnyType(Constant *Src, bool SrcIsSigned, Type *DstTy,
- bool DstIsSigned);
+ Value *
+ CastToAnyType(Value *Src, bool SrcIsSigned, Type *DstTy, bool DstIsSigned);
+ Constant *
+ CastToAnyType(Constant *Src, bool SrcIsSigned, Type *DstTy, bool DstIsSigned);

   /// CastFromSameSizeInteger - Cast an integer (or vector of integer) value to
   /// the given scalar (resp. vector of scalar) type of the same bitwidth.
@@ -420,8 +420,8 @@ private : // Helper functions.
   /// llvm.memset call with the specified operands. Returns DestPtr bitcast
   /// to i8*.
   Value *EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align);
- Value *EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size,
- unsigned Align);
+ Value *
+ EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align);
   Value *EmitMemSet(Value *DestPtr, Value *SrcVal, Value *Size, unsigned Align);

   /// EmitLandingPads - Emit EH landing pads.
@@ -568,14 +568,14 @@ private:
#endif
   Value *EmitReg_VEC_PACK_FIX_TRUNC_EXPR(tree_node *type, tree_node *op0,
                                          tree_node *op1);
- Value *EmitReg_VEC_PACK_TRUNC_EXPR(tree_node *type, tree_node *op0,
- tree_node *op1);
+ Value *
+ EmitReg_VEC_PACK_TRUNC_EXPR(tree_node *type, tree_node *op0, tree_node *op1);
   Value *EmitReg_VEC_WIDEN_MULT_HI_EXPR(tree_node *type, tree_node *op0,
                                         tree_node *op1);
   Value *EmitReg_VEC_WIDEN_MULT_LO_EXPR(tree_node *type, tree_node *op0,
                                         tree_node *op1);
- Value *EmitReg_WIDEN_MULT_EXPR(tree_node *type, tree_node *op0,
- tree_node *op1);
+ Value *
+ EmitReg_WIDEN_MULT_EXPR(tree_node *type, tree_node *op0, tree_node *op1);

   // Ternary expressions.
   Value *EmitReg_CondExpr(tree_node *op0, tree_node *op1, tree_node *op2);
@@ -592,8 +592,7 @@ private:
   Value *EmitCallOf(Value *Callee, gimple_statement_d *stmt,
                     const MemRef *DestLoc, const AttributeSet &PAL);
   CallInst *EmitSimpleCall(StringRef CalleeName, tree_node *ret_type,
- /* arguments */ ...)
- END_WITH_NULL;
+ /* arguments */ ...) END_WITH_NULL;
   Value *EmitFieldAnnotation(Value *FieldPtr, tree_node *FieldDecl);

   // Inline Assembly and Register Variables.
@@ -606,8 +605,8 @@ private:
   Value *BuildVectorShuffle(Value *InVec1, Value *InVec2, ...);
   Value *BuildBinaryAtomic(gimple_statement_d *stmt, AtomicRMWInst::BinOp Kind,
                            unsigned PostOp = 0);
- Value *BuildCmpAndSwapAtomic(gimple_statement_d *stmt, unsigned Bits,
- bool isBool);
+ Value *
+ BuildCmpAndSwapAtomic(gimple_statement_d *stmt, unsigned Bits, bool isBool);

   // Builtin Function Expansion.
   bool EmitBuiltinCall(gimple_statement_d *stmt, tree_node *fndecl,
@@ -616,8 +615,8 @@ private:
                                        tree_node *fndecl, const MemRef *DestLoc,
                                        Value *&Result);
   bool EmitBuiltinUnaryOp(Value *InVal, Value *&Result, Intrinsic::ID Id);
- Value *EmitBuiltinBitCountIntrinsic(gimple_statement_d *stmt,
- Intrinsic::ID Id);
+ Value *
+ EmitBuiltinBitCountIntrinsic(gimple_statement_d *stmt, Intrinsic::ID Id);
   Value *EmitBuiltinSQRT(gimple_statement_d *stmt);
   Value *EmitBuiltinPOWI(gimple_statement_d *stmt);
   Value *EmitBuiltinPOW(gimple_statement_d *stmt);

Modified: dragonegg/trunk/include/dragonegg/TypeConversion.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/TypeConversion.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/dragonegg/TypeConversion.h (original)
+++ dragonegg/trunk/include/dragonegg/TypeConversion.h Mon Feb 25 04:54:25 2013
@@ -62,8 +62,8 @@ extern llvm::Type *GetUnitType(llvm::LLV
/// GetUnitPointerType - Returns an LLVM pointer type which points to memory one
/// address unit wide. For example, on a machine which has 16 bit bytes returns
/// an i16*.
-extern llvm::Type *GetUnitPointerType(llvm::LLVMContext &C,
- unsigned AddrSpace = 0);
+extern llvm::Type *
+GetUnitPointerType(llvm::LLVMContext &C, unsigned AddrSpace = 0);

/// isSizeCompatible - Return true if the specified gcc type is guaranteed to be
/// turned by ConvertType into an LLVM type of the same size (i.e. TYPE_SIZE the
@@ -88,9 +88,9 @@ extern llvm::Type *ConvertType(tree_node
/// ConvertFunctionType - Convert the specified FUNCTION_TYPE or METHOD_TYPE
/// tree to an LLVM type. This does the same thing that ConvertType does, but
/// it also returns the function's LLVM calling convention and attributes.
-extern llvm::FunctionType *ConvertFunctionType(
- tree_node *type, tree_node *decl, tree_node *static_chain,
- llvm::CallingConv::ID &CC, llvm::AttributeSet &PAL);
+extern llvm::FunctionType *
+ConvertFunctionType(tree_node *type, tree_node *decl, tree_node *static_chain,
+ llvm::CallingConv::ID &CC, llvm::AttributeSet &PAL);

/// ConvertArgListToFnType - Given a DECL_ARGUMENTS list on an GCC tree,
/// return the LLVM type corresponding to the function. This is useful for

Modified: dragonegg/trunk/include/x86/dragonegg/Target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/x86/dragonegg/Target.h?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/include/x86/dragonegg/Target.h (original)
+++ dragonegg/trunk/include/x86/dragonegg/Target.h Mon Feb 25 04:54:25 2013
@@ -125,8 +125,8 @@ extern bool llvm_x86_should_pass_aggrega
#define LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(X, Y, Z) \
   llvm_x86_should_pass_aggregate_in_integer_regs((X), (Y), (Z))

-extern Type *llvm_x86_scalar_type_for_struct_return(tree_node *type,
- unsigned *Offset);
+extern Type *
+llvm_x86_scalar_type_for_struct_return(tree_node *type, unsigned *Offset);

/* LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be
    returned as a scalar, otherwise return NULL. */
@@ -205,9 +205,9 @@ extern bool llvm_x86_32_should_pass_aggr
     tree_node *, Type *Ty, std::vector<Type *> &);

#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \
- (TARGET_64BIT ? \
- llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) : \
- llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E)))
+ (TARGET_64BIT \
+ ? llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) \
+ : llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E)))

extern bool llvm_x86_64_aggregate_partially_passed_in_regs(
     std::vector<Type *> &, std::vector<Type *> &, bool);

Modified: dragonegg/trunk/src/Aliasing.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Aliasing.cpp?rev=176016&r1=176015&r2=176016&view=diff

--- dragonegg/trunk/src/Aliasing.cpp (original)
+++ dragonegg/trunk/src/Aliasing.cpp Mon Feb 25 04:54:25 2013
@@ -120,7 +120,7 @@ MDNode *describeAliasSet(tree t) {

   // If there is a path from this node to any leaf node then it is not a leaf
   // node and can be discarded.
- for (unsigned i = 0, e = (unsigned)LeafNodes.size(); i != e; ++i)
+ for (unsigned i = 0, e = (unsigned) LeafNodes.size(); i != e; ++i)

Space between a cast an its operands? I don't recall that being a
'thing' we do in the LLVM codebase generally.

Hi David,

I hope I didn’t miss anything. Please feel free to just file bug reports. That makes tracking and fixing these issues much easier.

Cheers,
Daniel