Skip to content

Commit

Permalink
Avoid using reserved identifiers as include guards (#4063)
Browse files Browse the repository at this point in the history
* Avoid using reserved identifiers as include guards

Batch-processed by

$ git ls-tree --full-tree --name-only -r HEAD | grep '[.]h$' | while read filename; do  sed -Ei -e 's/^(#(define|ifndef)\s+)_([A-Z0-9_]+_H_)$/\1\3/' -e 's,^(#endif\s+)(/\*\s+_([A-Z0-9_]+_H_)\s+\*/|//\s+_([A-Z0-9_]+_H_))\s*$,\1/* \3\4 */,' $filename; done

Identifiers of the following forms are reserved:

- identifiers with a double underscore anywhere;
- identifiers that begin with an underscore followed by an uppercase letter;
- in the global namespace, identifiers that begin with an underscore.

We should not use reserved identifiers. More e.g. at https://en.cppreference.com/w/cpp/language/identifiers

* Fix inconsistent end guards

* Fix clang-format inconsistencies of guard ends

* Also fix include guard in ir-generated
  • Loading branch information
vlstill authored Jul 14, 2023
1 parent ee5a5b7 commit e255d59
Show file tree
Hide file tree
Showing 193 changed files with 577 additions and 577 deletions.
6 changes: 3 additions & 3 deletions backends/ebpf/codeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_CODEGEN_H_
#define _BACKENDS_EBPF_CODEGEN_H_
#ifndef BACKENDS_EBPF_CODEGEN_H_
#define BACKENDS_EBPF_CODEGEN_H_

#include "frontends/p4/typeMap.h"
#include "ir/ir.h"
Expand Down Expand Up @@ -139,4 +139,4 @@ class EBPFInitializerUtils {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_CODEGEN_H_ */
#endif /* BACKENDS_EBPF_CODEGEN_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFBACKEND_H_
#define _BACKENDS_EBPF_EBPFBACKEND_H_
#ifndef BACKENDS_EBPF_EBPFBACKEND_H_
#define BACKENDS_EBPF_EBPFBACKEND_H_

#include "ebpfObject.h"
#include "ebpfOptions.h"
Expand All @@ -29,4 +29,4 @@ void run_ebpf_backend(const EbpfOptions &options, const IR::ToplevelBlock *tople

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFBACKEND_H_ */
#endif /* BACKENDS_EBPF_EBPFBACKEND_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFCONTROL_H_
#define _BACKENDS_EBPF_EBPFCONTROL_H_
#ifndef BACKENDS_EBPF_EBPFCONTROL_H_
#define BACKENDS_EBPF_EBPFCONTROL_H_

#include "ebpfObject.h"
#include "ebpfTable.h"
Expand Down Expand Up @@ -95,4 +95,4 @@ class EBPFControl : public EBPFObject {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFCONTROL_H_ */
#endif /* BACKENDS_EBPF_EBPFCONTROL_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfDeparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _BACKENDS_EBPF_EBPFDEPARSER_H_
#define _BACKENDS_EBPF_EBPFDEPARSER_H_
#ifndef BACKENDS_EBPF_EBPFDEPARSER_H_
#define BACKENDS_EBPF_EBPFDEPARSER_H_

#include "ebpfControl.h"

Expand Down Expand Up @@ -93,4 +93,4 @@ class EBPFDeparser : public EBPFControl {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFDEPARSER_H_ */
#endif /* BACKENDS_EBPF_EBPFDEPARSER_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFMODEL_H_
#define _BACKENDS_EBPF_EBPFMODEL_H_
#ifndef BACKENDS_EBPF_EBPFMODEL_H_
#define BACKENDS_EBPF_EBPFMODEL_H_

#include "frontends/common/model.h"
#include "frontends/p4/coreLibrary.h"
Expand Down Expand Up @@ -82,4 +82,4 @@ class EBPFModel : public ::Model::Model {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFMODEL_H_ */
#endif /* BACKENDS_EBPF_EBPFMODEL_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFOBJECT_H_
#define _BACKENDS_EBPF_EBPFOBJECT_H_
#ifndef BACKENDS_EBPF_EBPFOBJECT_H_
#define BACKENDS_EBPF_EBPFOBJECT_H_

#include "codeGen.h"
#include "ebpfModel.h"
Expand Down Expand Up @@ -58,4 +58,4 @@ class EBPFObject : public ICastable {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFOBJECT_H_ */
#endif /* BACKENDS_EBPF_EBPFOBJECT_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFOPTIONS_H_
#define _BACKENDS_EBPF_EBPFOPTIONS_H_
#ifndef BACKENDS_EBPF_EBPFOPTIONS_H_
#define BACKENDS_EBPF_EBPFOPTIONS_H_

#include <getopt.h>

Expand Down Expand Up @@ -71,4 +71,4 @@ class EbpfOptions : public CompilerOptions {

using EbpfContext = P4CContextWithOptions<EbpfOptions>;

#endif /* _BACKENDS_EBPF_EBPFOPTIONS_H_ */
#endif /* BACKENDS_EBPF_EBPFOPTIONS_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFPARSER_H_
#define _BACKENDS_EBPF_EBPFPARSER_H_
#ifndef BACKENDS_EBPF_EBPFPARSER_H_
#define BACKENDS_EBPF_EBPFPARSER_H_

#include "ebpfObject.h"
#include "ebpfProgram.h"
Expand Down Expand Up @@ -104,4 +104,4 @@ class EBPFParser : public EBPFObject {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFPARSER_H_ */
#endif /* BACKENDS_EBPF_EBPFPARSER_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFPROGRAM_H_
#define _BACKENDS_EBPF_EBPFPROGRAM_H_
#ifndef BACKENDS_EBPF_EBPFPROGRAM_H_
#define BACKENDS_EBPF_EBPFPROGRAM_H_

#include "codeGen.h"
#include "ebpfModel.h"
Expand Down Expand Up @@ -97,4 +97,4 @@ class EBPFProgram : public EBPFObject {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFPROGRAM_H_ */
#endif /* BACKENDS_EBPF_EBPFPROGRAM_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFTABLE_H_
#define _BACKENDS_EBPF_EBPFTABLE_H_
#ifndef BACKENDS_EBPF_EBPFTABLE_H_
#define BACKENDS_EBPF_EBPFTABLE_H_

#include "ebpfObject.h"
#include "ebpfProgram.h"
Expand Down Expand Up @@ -182,4 +182,4 @@ class EBPFValueSet : public EBPFTableBase {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFTABLE_H_ */
#endif /* BACKENDS_EBPF_EBPFTABLE_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/ebpfType.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_EBPFTYPE_H_
#define _BACKENDS_EBPF_EBPFTYPE_H_
#ifndef BACKENDS_EBPF_EBPFTYPE_H_
#define BACKENDS_EBPF_EBPFTYPE_H_

#include "ebpfObject.h"
#include "ir/ir.h"
Expand Down Expand Up @@ -184,4 +184,4 @@ class EBPFEnumType : public EBPFType, public EBPF::IHasWidth {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_EBPFTYPE_H_ */
#endif /* BACKENDS_EBPF_EBPFTYPE_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_LOWER_H_
#define _BACKENDS_EBPF_LOWER_H_
#ifndef BACKENDS_EBPF_LOWER_H_
#define BACKENDS_EBPF_LOWER_H_

#include "frontends/common/resolveReferences/resolveReferences.h"
#include "frontends/p4/typeChecking/typeChecker.h"
Expand Down Expand Up @@ -57,4 +57,4 @@ class Lower : public PassManager {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_LOWER_H_ */
#endif /* BACKENDS_EBPF_LOWER_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_MIDEND_H_
#define _BACKENDS_EBPF_MIDEND_H_
#ifndef BACKENDS_EBPF_MIDEND_H_
#define BACKENDS_EBPF_MIDEND_H_

#include "ebpfOptions.h"
#include "frontends/common/resolveReferences/referenceMap.h"
Expand All @@ -38,4 +38,4 @@ class MidEnd {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_MIDEND_H_ */
#endif /* BACKENDS_EBPF_MIDEND_H_ */
6 changes: 3 additions & 3 deletions backends/ebpf/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_EBPF_TARGET_H_
#define _BACKENDS_EBPF_TARGET_H_
#ifndef BACKENDS_EBPF_TARGET_H_
#define BACKENDS_EBPF_TARGET_H_

#include "lib/cstring.h"
#include "lib/error.h"
Expand Down Expand Up @@ -269,4 +269,4 @@ class TestTarget : public EBPF::KernelSamplesTarget {

} // namespace EBPF

#endif /* _BACKENDS_EBPF_TARGET_H_ */
#endif /* BACKENDS_EBPF_TARGET_H_ */
6 changes: 3 additions & 3 deletions backends/graphs/controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_GRAPHS_CONTROLS_H_
#define _BACKENDS_GRAPHS_CONTROLS_H_
#ifndef BACKENDS_GRAPHS_CONTROLS_H_
#define BACKENDS_GRAPHS_CONTROLS_H_

#include "graphs.h"

Expand Down Expand Up @@ -68,4 +68,4 @@ class ControlGraphs : public Graphs {

} // namespace graphs

#endif /* _BACKENDS_GRAPHS_CONTROLS_H_ */
#endif /* BACKENDS_GRAPHS_CONTROLS_H_ */
6 changes: 3 additions & 3 deletions backends/graphs/graph_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "graphs.h"
#include "lib/json.h"

#ifndef _BACKENDS_GRAPHS_GRAPH_VISITOR_H_
#define _BACKENDS_GRAPHS_GRAPH_VISITOR_H_
#ifndef BACKENDS_GRAPHS_GRAPH_VISITOR_H_
#define BACKENDS_GRAPHS_GRAPH_VISITOR_H_

namespace graphs {

Expand Down Expand Up @@ -137,4 +137,4 @@ class Graph_visitor : public Graphs {

} // namespace graphs

#endif /* _BACKENDS_GRAPHS_GRAPH_VISITOR_H_ */
#endif /* BACKENDS_GRAPHS_GRAPH_VISITOR_H_ */
6 changes: 3 additions & 3 deletions backends/graphs/graphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_GRAPHS_GRAPHS_H_
#define _BACKENDS_GRAPHS_GRAPHS_H_
#ifndef BACKENDS_GRAPHS_GRAPHS_H_
#define BACKENDS_GRAPHS_GRAPHS_H_

#include "config.h"

Expand Down Expand Up @@ -225,4 +225,4 @@ class Graphs : public Inspector {

} // namespace graphs

#endif // _BACKENDS_GRAPHS_GRAPHS_H_
#endif /* BACKENDS_GRAPHS_GRAPHS_H_ */
6 changes: 3 additions & 3 deletions backends/graphs/parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

#ifndef _BACKENDS_GRAPHS_PARSERS_H_
#define _BACKENDS_GRAPHS_PARSERS_H_
#ifndef BACKENDS_GRAPHS_PARSERS_H_
#define BACKENDS_GRAPHS_PARSERS_H_

#include "frontends/common/resolveReferences/referenceMap.h"
#include "graphs.h"
Expand Down Expand Up @@ -61,4 +61,4 @@ class ParserGraphs : public Graphs {

} // namespace graphs

#endif /* _BACKENDS_GRAPHS_PARSERS_H_ */
#endif /* BACKENDS_GRAPHS_PARSERS_H_ */
6 changes: 3 additions & 3 deletions backends/p4test/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_P4TEST_MIDEND_H_
#define _BACKENDS_P4TEST_MIDEND_H_
#ifndef BACKENDS_P4TEST_MIDEND_H_
#define BACKENDS_P4TEST_MIDEND_H_

#include "frontends/common/options.h"
#include "frontends/p4/evaluator/evaluator.h"
Expand All @@ -42,4 +42,4 @@ class MidEnd : public PassManager {

} // namespace P4Test

#endif /* _BACKENDS_P4TEST_MIDEND_H_ */
#endif /* BACKENDS_P4TEST_MIDEND_H_ */
6 changes: 3 additions & 3 deletions backends/ubpf/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKENDS_UBPF_MIDEND_H_
#define _BACKENDS_UBPF_MIDEND_H_
#ifndef BACKENDS_UBPF_MIDEND_H_
#define BACKENDS_UBPF_MIDEND_H_

#include "backends/ebpf/ebpfOptions.h"
#include "backends/ebpf/midend.h"
Expand All @@ -32,4 +32,4 @@ class MidEnd : public EBPF::MidEnd {

} // namespace UBPF

#endif /* _BACKENDS_UBPF_MIDEND_H_ */
#endif /* BACKENDS_UBPF_MIDEND_H_ */
6 changes: 3 additions & 3 deletions frontends/common/constantFolding.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _COMMON_CONSTANTFOLDING_H_
#define _COMMON_CONSTANTFOLDING_H_
#ifndef COMMON_CONSTANTFOLDING_H_
#define COMMON_CONSTANTFOLDING_H_

#include "frontends/p4/typeChecking/typeChecker.h"
#include "ir/ir.h"
Expand Down Expand Up @@ -167,4 +167,4 @@ class ConstantFolding : public PassManager {

} // namespace P4

#endif /* _COMMON_CONSTANTFOLDING_H_ */
#endif /* COMMON_CONSTANTFOLDING_H_ */
6 changes: 3 additions & 3 deletions frontends/common/constantParsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _FRONTENDS_COMMON_CONSTANTPARSING_H_
#define _FRONTENDS_COMMON_CONSTANTPARSING_H_
#ifndef FRONTENDS_COMMON_CONSTANTPARSING_H_
#define FRONTENDS_COMMON_CONSTANTPARSING_H_

#include "lib/cstring.h"

Expand Down Expand Up @@ -86,4 +86,4 @@ IR::Constant *parseConstant(const Util::SourceInfo &srcInfo, const UnparsedConst
*/
int parseConstantChecked(const Util::SourceInfo &srcInfo, const UnparsedConstant &constant);

#endif /* _FRONTENDS_COMMON_CONSTANTPARSING_H_ */
#endif /* FRONTENDS_COMMON_CONSTANTPARSING_H_ */
6 changes: 3 additions & 3 deletions frontends/common/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _FRONTENDS_COMMON_MODEL_H_
#define _FRONTENDS_COMMON_MODEL_H_
#ifndef FRONTENDS_COMMON_MODEL_H_
#define FRONTENDS_COMMON_MODEL_H_

#include "ir/id.h"
#include "lib/cstring.h"
Expand Down Expand Up @@ -65,4 +65,4 @@ class Model {};

} // namespace Model

#endif /* _FRONTENDS_COMMON_MODEL_H_ */
#endif /* FRONTENDS_COMMON_MODEL_H_ */
Loading

0 comments on commit e255d59

Please sign in to comment.