Skip to content

Commit

Permalink
Fix indentation in CheckedCInterop.cpp (#606)
Browse files Browse the repository at this point in the history
Cherry-picked from commit d83ad07

    LLVM/Clang follow an 80-char line limit.
  • Loading branch information
Mandeep Singh Grang committed Sep 27, 2019
1 parent f1649bd commit 5604b36
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions clang/lib/Sema/CheckedCInterop.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===------ CheckedCInterop - Support Methods for Checked C Interop -----===//
//===------ CheckedCInterop - Support Methods for Checked C Interop ------===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -20,8 +20,7 @@ using namespace sema;
/// \brief Create the corresponding Checked C interop type for Ty, given a
/// a bounds expression Bounds. Returns the empty type if no interop
/// type exists.
QualType Sema::SynthesizeInteropType(QualType Ty,
bool isParam) {
QualType Sema::SynthesizeInteropType(QualType Ty, bool isParam) {
// Nothing to do.
if (Ty.isNull() || Ty->isCheckedArrayType() ||
Ty->isCheckedPointerType())
Expand Down Expand Up @@ -103,15 +102,16 @@ class TransformFunctionTypeToChecked :

const FunctionProtoType *T = TL.getTypePtr();

// Assert on trailing returning type for now, instead of handling them.
// That's a C++ feature that we cannot test right now.
// Assert on trailing returning type for now, instead of handling them.
// That's a C++ feature that we cannot test right now.
if (T->hasTrailingReturn()) {
assert(false && "Unexpected trailing return type for Checked C");
return QualType();
}

// Update the parameters and return types to be their interop types. Also
// update the extend prototype inofmration to remove interop type annotations.
// update the extend prototype inofmration to remove interop type
// annotations.
SmallVector<QualType, 4> CurrentParamTypes;
SmallVector<BoundsAnnotations, 4> CurrentParamAnnots;
TypeLoc ResultLoc = TL.getReturnLoc();
Expand Down Expand Up @@ -140,8 +140,9 @@ class TransformFunctionTypeToChecked :
llvm::outs() << "\nresult type = ";
ResultLoc.getType().dump(llvm::outs());
#endif
// Construct new annotations that do not have the bounds-safe interface type.
if (Bounds) {
// Construct new annotations that do not have the bounds-safe
// interface type.
if (Bounds) {
EPI.ReturnAnnots = BoundsAnnotations(Bounds, nullptr);
} else
EPI.ReturnAnnots = BoundsAnnotations();
Expand All @@ -150,11 +151,12 @@ class TransformFunctionTypeToChecked :
}
}

// Update the parameter types and annotations. The EPI parameter array is still used
// by the original type, so a create and update a copy in CurrentParamAnnots.
// Update the parameter types and annotations. The EPI parameter array is
// still used by the original type, so a create and update a copy in
// CurrentParamAnnots.
if (EPI.ParamAnnots) {
// Track whether there are parameter annotations left after removing interop
// annotations.
// Track whether there are parameter annotations left after removing
// interop annotations.
bool hasParamAnnots = false;
for (unsigned int i = 0; i < CurrentParamTypes.size(); i++) {
BoundsAnnotations IndividualAnnots = EPI.ParamAnnots[i];
Expand Down Expand Up @@ -213,9 +215,9 @@ class TransformFunctionTypeToChecked :
SmallVector<QualType, 4> ParamTypes;
SmallVector<ParmVarDecl*, 4> ParamDecls;
Sema::ExtParameterInfoBuilder ExtParamInfos;
// ParamAnnotsStorage is pre-allocated storage that is used when updating EPI
// in TransformExtendedParameterInfo. Its lifetime must last until the end of
// the lifetime of EPI.
// ParamAnnotsStorage is pre-allocated storage that is used when updating
// EPI in TransformExtendedParameterInfo. Its lifetime must last until the
// end of the lifetime of EPI.
SmallVector<BoundsAnnotations, 4> ParamAnnotsStorage;

QualType ResultType = getDerived().TransformType(TLB, ResultLoc);
Expand All @@ -240,7 +242,8 @@ class TransformFunctionTypeToChecked :
QualType Result = TL.getType();
if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) {
Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
Result =
getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
if (Result.isNull()) {
#if TRACE_INTEROP
llvm::outs() << "Rebuild function prototype failed";
Expand All @@ -265,8 +268,8 @@ class TransformFunctionTypeToChecked :
}

QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
// Preserve typedef information, unless the underlying type has a function type
// embedded in it with a bounds-safe interface.
// Preserve typedef information, unless the underlying type has a function
// type embedded in it with a bounds-safe interface.
const TypedefType *T = TL.getTypePtr();
// See if the underlying type changes.
QualType UnderlyingType = T->desugar();
Expand All @@ -282,14 +285,14 @@ class TransformFunctionTypeToChecked :
// and use the underlying transformed type.

// Synthesize some dummy type source information.
TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(TransformedType,
getDerived().getBaseLocation());
TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
TransformedType, getDerived().getBaseLocation());
// Use that to get dummy location information.
TypeLoc NewTL = DI->getTypeLoc();
TLB.reserve(NewTL.getFullDataSize());
// Re-run the type transformation with the dummy location information so
// that the type location class pushed on to the TypeBuilder is the matching
// class for the underlying type.
// that the type location class pushed on to the TypeBuilder is the
// matching class for the underlying type.
QualType Result = getDerived().TransformType(TLB, NewTL);
assert(Result == TransformedType);
return Result;
Expand Down

0 comments on commit 5604b36

Please sign in to comment.