Skip to content

Commit 7579795

Browse files
committed
clang_format fixes
Signed-off-by: Chris Dodd <cdodd@nvidia.com>
1 parent 72dc99e commit 7579795

18 files changed

Lines changed: 69 additions & 64 deletions

backends/tofino/bf-p4c/phv/analysis/mutex_overlay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool ExcludeParserLoopReachableFields::is_loop_reachable(
5454
}
5555

5656
IR::Ptr<IR::Node> ExcludeParserLoopReachableFields::apply_visitor(const IR::Node *root,
57-
const char *) {
57+
const char *) {
5858
for (auto &kv : fieldToStates.field_to_parser_states) {
5959
for (auto &xk : fieldToStates.field_to_parser_states) {
6060
if (kv.first == xk.first || kv.first->gress != xk.first->gress) continue;

frontends/common/applyOptionsPragmas.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ std::optional<IOptionPragmaParser::CommandLineOptions> P4COptionPragmaParser::tr
4444
if (supportCommandLinePragma && pragmaName == "command_line") {
4545
IOptionPragmaParser::CommandLineOptions options;
4646
auto args = annotation->needsParsing()
47-
? P4ParserDriver::parseExpressionList(annotation->srcInfo,
48-
annotation->getUnparsed())
49-
: IR::Ptr<IR::Vector<IR::Expression>>(&annotation->getExpr());
47+
? P4ParserDriver::parseExpressionList(annotation->srcInfo,
48+
annotation->getUnparsed())
49+
: IR::Ptr<IR::Vector<IR::Expression>>(&annotation->getExpr());
5050
for (const IR::Expression *arg : *args) {
5151
if (auto *a = arg->to<IR::StringLiteral>()) {
5252
options.push_back(a->value.c_str());

frontends/common/parseInput.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ IR::Ptr<IR::P4Program> parseP4String(const char *sourceFile, unsigned sourceLine
2929
const std::string &input,
3030
CompilerOptions::FrontendVersion version) {
3131
std::istringstream stream(input);
32-
auto result = (version == CompilerOptions::FrontendVersion::P4_14)
32+
auto result =
33+
(version == CompilerOptions::FrontendVersion::P4_14)
3334
? parseV1Program<std::istringstream &, P4V1::Converter>(stream, sourceFile, sourceLine)
3435
: P4ParserDriver::parse(stream, sourceFile, sourceLine);
3536

frontends/p4/inlining.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ struct InlineSummary : public IHasDbPrint {
155155
/// For each instance (key) we must apply a bunch of substitutions
156156
std::map<IR::Ptr<IR::Declaration_Instance>, PerInstanceSubstitutions *> substitutions;
157157
/// For each invocation (key) call the instance that is invoked.
158-
std::map<IR::Ptr<IR::MethodCallStatement>, IR::Ptr<IR::Declaration_Instance>> callToInstance;
158+
std::map<IR::Ptr<IR::MethodCallStatement>, IR::Ptr<IR::Declaration_Instance>>
159+
callToInstance;
159160

160161
/**
161162
* For each distinct invocation of the subparser identified by InlinedInvocationInfo

frontends/p4/parseAnnotations.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace P4 {
2626
// Parses an annotation with a single-element body.
2727
#define PARSE(aname, tname) \
2828
{aname, [](IR::Annotation *annotation) { \
29-
IR::Ptr<IR::tname> parsed = \
29+
IR::Ptr<IR::tname> parsed = \
3030
P4::P4ParserDriver::parse##tname(annotation->srcInfo, annotation->getUnparsed()); \
3131
if (parsed != nullptr) { \
3232
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(parsed); \
@@ -35,19 +35,19 @@ namespace P4 {
3535
}}
3636

3737
// Parses an annotation that is either an integer constant or a string literal.
38-
#define PARSE_CONSTANT_OR_STRING_LITERAL(aname) \
39-
{aname, [](IR::Annotation *annotation) { \
38+
#define PARSE_CONSTANT_OR_STRING_LITERAL(aname) \
39+
{aname, [](IR::Annotation *annotation) { \
4040
IR::Ptr<IR::Expression> parsed = P4::P4ParserDriver::parseConstantOrStringLiteral( \
41-
annotation->srcInfo, annotation->getUnparsed()); \
42-
if (parsed != nullptr) { \
43-
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(parsed); \
44-
} \
45-
return parsed != nullptr; \
41+
annotation->srcInfo, annotation->getUnparsed()); \
42+
if (parsed != nullptr) { \
43+
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(parsed); \
44+
} \
45+
return parsed != nullptr; \
4646
}}
4747

4848
#define PARSE_CONSTANT(aname) \
4949
{aname, [](IR::Annotation *annotation) { \
50-
IR::Ptr<IR::Expression> parsed = \
50+
IR::Ptr<IR::Expression> parsed = \
5151
P4::P4ParserDriver::parseConstant(annotation->srcInfo, annotation->getUnparsed()); \
5252
if (parsed != nullptr) { \
5353
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(parsed); \
@@ -57,7 +57,7 @@ namespace P4 {
5757

5858
#define PARSE_STRING_LITERAL(aname) \
5959
{aname, [](IR::Annotation *annotation) { \
60-
IR::Ptr<IR::Expression> parsed = P4::P4ParserDriver::parseStringLiteral( \
60+
IR::Ptr<IR::Expression> parsed = P4::P4ParserDriver::parseStringLiteral( \
6161
annotation->srcInfo, annotation->getUnparsed()); \
6262
if (parsed != nullptr) { \
6363
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(parsed); \
@@ -66,27 +66,27 @@ namespace P4 {
6666
}}
6767

6868
// Parses an annotation whose body is a pair.
69-
#define PARSE_PAIR(aname, tname) \
70-
{aname, [](IR::Annotation *annotation) { \
71-
IR::Ptr<IR::Vector<IR::Expression>> parsed = P4::P4ParserDriver::parse##tname##Pair( \
72-
annotation->srcInfo, annotation->getUnparsed()); \
73-
if (parsed != nullptr) { \
74-
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(*parsed); \
75-
} \
76-
return parsed != nullptr; \
77-
}}
78-
79-
// Parses an annotation whose body is a triple.
80-
#define PARSE_TRIPLE(aname, tname) \
69+
#define PARSE_PAIR(aname, tname) \
8170
{aname, [](IR::Annotation *annotation) { \
82-
IR::Ptr<IR::Vector<IR::Expression>> parsed = P4::P4ParserDriver::parse##tname##Triple( \
71+
IR::Ptr<IR::Vector<IR::Expression>> parsed = P4::P4ParserDriver::parse##tname##Pair( \
8372
annotation->srcInfo, annotation->getUnparsed()); \
8473
if (parsed != nullptr) { \
8574
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(*parsed); \
8675
} \
8776
return parsed != nullptr; \
8877
}}
8978

79+
// Parses an annotation whose body is a triple.
80+
#define PARSE_TRIPLE(aname, tname) \
81+
{aname, [](IR::Annotation *annotation) { \
82+
IR::Ptr<IR::Vector<IR::Expression>> parsed = P4::P4ParserDriver::parse##tname##Triple( \
83+
annotation->srcInfo, annotation->getUnparsed()); \
84+
if (parsed != nullptr) { \
85+
annotation->body.emplace<IR::Annotation::ExpressionAnnotation>(*parsed); \
86+
} \
87+
return parsed != nullptr; \
88+
}}
89+
9090
// Parses an annotation whose body is a list of expressions.
9191
#define PARSE_EXPRESSION_LIST(aname) {aname, &P4::ParseAnnotations::parseExpressionList}
9292

frontends/p4/typeChecking/typeCheckDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ const IR::Node *TypeInferenceBase::postorder(const IR::SerEnumMember *member) {
432432
ConstantTypeSubstitution cts(tvs, typeMap, this);
433433
auto newValue = cts.convert(member->value, getChildContext()); // sets type
434434
IR::Ptr<IR::SerEnumMember> rv = member;
435-
if (rv->value != newValue)
436-
rv = new IR::SerEnumMember(rv->srcInfo, rv->name, newValue);
435+
if (rv->value != newValue) rv = new IR::SerEnumMember(rv->srcInfo, rv->name, newValue);
437436
if (!typeMap->getType(rv)) setType(rv, getTypeType(serEnum));
438437
return rv; // will always be in typeMap, so this won't dangle
439438
}

frontends/p4/typeChecking/typeChecker.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ IR::Ptr<IR::Expression> TypeInferenceBase::constantFold(const IR::Expression *ex
7373
// Make a clone of the type where all type variables in
7474
// the type parameters are replaced with fresh ones.
7575
// This should only be applied to canonical types.
76-
IR::Ptr<IR::Type> TypeInferenceBase::cloneWithFreshTypeVariables(const IR::IMayBeGenericType *type) {
76+
IR::Ptr<IR::Type> TypeInferenceBase::cloneWithFreshTypeVariables(
77+
const IR::IMayBeGenericType *type) {
7778
TypeVariableSubstitution tvs;
7879
for (auto v : type->getTypeParameters()->parameters) {
7980
auto tv = new IR::Type_Var(v->srcInfo, v->getName());
@@ -189,7 +190,7 @@ TypeVariableSubstitution *TypeInferenceBase::unifyBase(
189190

190191
template <class Ctor>
191192
IR::Ptr<IR::Type> TypeInferenceBase::canonicalizeFields(const IR::Type_StructLike *type,
192-
Ctor constructor) {
193+
Ctor constructor) {
193194
bool changes = false;
194195
IR::IndexedVector<IR::StructField> fields;
195196
for (auto field : type->fields) {
@@ -933,7 +934,7 @@ TypeInferenceBase::containerInstantiation(
933934

934935
auto returnType = tvs->lookup(rettype);
935936
BUG_CHECK(returnType != nullptr, "Cannot infer constructor result type %1%", node);
936-
return { returnType, newArgs };
937+
return {returnType, newArgs};
937938
}
938939

939940
const IR::Node *TypeInferenceBase::postorder(const IR::Argument *arg) {

frontends/p4/typeMap.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,6 @@ int TypeMap::widthBits(const IR::Type *type, const IR::Node *errorPosition, bool
399399
return -1;
400400
}
401401

402-
void dump(TypeMap *typeMap) {
403-
std::cout <<*typeMap << std::endl;
404-
}
402+
void dump(TypeMap *typeMap) { std::cout << *typeMap << std::endl; }
405403

406404
} // namespace P4

frontends/p4/typeMap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class TypeMap final : public ProgramMap {
6363
#if !HAVE_LIBGC
6464
BUG_CHECK(element->check_referenced(), "checking unreferenced node in typeMap");
6565
#endif
66-
return typeMap.count(element) != 0; }
66+
return typeMap.count(element) != 0;
67+
}
6768
void setType(IR::Ptr<IR::Node> element, const IR::Type *type);
6869
IR::Ptr<IR::Type> getType(const IR::Node *element, bool notNull = false) const;
6970
// unwraps a TypeType into its contents

frontends/parsers/parserDriver.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ class P4ParserDriver final : public AbstractParserDriver {
139139

140140
// Singletons ////////////////////////////////////////////////////////////
141141
static IR::Ptr<IR::Expression> parseExpression(const Util::SourceInfo &srcInfo,
142-
const IR::Vector<IR::AnnotationToken> &body);
142+
const IR::Vector<IR::AnnotationToken> &body);
143143

144144
static IR::Ptr<IR::Constant> parseConstant(const Util::SourceInfo &srcInfo,
145-
const IR::Vector<IR::AnnotationToken> &body);
145+
const IR::Vector<IR::AnnotationToken> &body);
146146

147147
static IR::Ptr<IR::Expression> parseConstantOrStringLiteral(
148148
const Util::SourceInfo &srcInfo, const IR::Vector<IR::AnnotationToken> &body);
149149

150-
static IR::Ptr<IR::StringLiteral> parseStringLiteral(const Util::SourceInfo &srcInfo,
151-
const IR::Vector<IR::AnnotationToken> &body);
150+
static IR::Ptr<IR::StringLiteral> parseStringLiteral(
151+
const Util::SourceInfo &srcInfo, const IR::Vector<IR::AnnotationToken> &body);
152152

153153
// Pairs /////////////////////////////////////////////////////////////////
154154
static IR::Ptr<IR::Vector<IR::Expression>> parseExpressionPair(

0 commit comments

Comments
 (0)