Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is proper LLVM header guard style?

In clang tidy, the check [llvm-header-guard] looks for LLVM style header guards, but I can't find any examples of proper LLVM header guard style, specifically the structure of the name given to the define, the coding standards pages does not mention anything.

like image 606
A-n-t-h-o-n-y Avatar asked May 09 '17 22:05

A-n-t-h-o-n-y


2 Answers

Looking at the unit tests:

  • https://github.com/llvm-mirror/clang-tools-extra/blob/master/unittests/clang-tidy/LLVMModuleTest.cpp

it seems to accept a few variations on the commonly used patterns. For a file named include/llvm/ADT/foo.h the convention seems to be:

#ifndef LLVM_ADT_FOO_H
#define LLVM_ADT_FOO_H
//...
#endif // LLVM_ADT_FOO_H
like image 92
gavinb Avatar answered Sep 20 '22 14:09

gavinb


Presumably the LLVM codebase adheres to the LLVM coding standards, so one can simply look at a few LLVM header files to get an idea of what the guard looks like. Here are some random LLVM header files I looked at:

https://github.com/llvm-mirror/llvm/blob/master/include/llvm/CodeGen/SelectionDAG.h

https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Support/AlignOf.h

Based on those files, I think the header guard looks like this:

#ifndef LLVM_CODEGEN_SELECTIONDAG_H
#define LLVM_CODEGEN_SELECTIONDAG_H
...
#endif
like image 22
David Grayson Avatar answered Sep 18 '22 14:09

David Grayson