Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
Show All 13 Lines | |||||
using namespace clang::ast_matchers; | using namespace clang::ast_matchers; | ||||
namespace clang { | namespace clang { | ||||
namespace tidy { | namespace tidy { | ||||
namespace altera { | namespace altera { | ||||
void StructPackAlignCheck::registerMatchers(MatchFinder *Finder) { | void StructPackAlignCheck::registerMatchers(MatchFinder *Finder) { | ||||
Finder->addMatcher(recordDecl(isStruct(), isDefinition(), | Finder->addMatcher( | ||||
unless(isExpansionInSystemHeader())) | recordDecl(isStruct(), isDefinition(), | ||||
unless(anyOf(isExpansionInSystemHeader(), isImplicit()))) | |||||
.bind("struct"), | .bind("struct"), | ||||
this); | this); | ||||
} | } | ||||
CharUnits | CharUnits | ||||
StructPackAlignCheck::computeRecommendedAlignment(CharUnits MinByteSize) { | StructPackAlignCheck::computeRecommendedAlignment(CharUnits MinByteSize) { | ||||
CharUnits NewAlign = CharUnits::fromQuantity(1); | CharUnits NewAlign = CharUnits::fromQuantity(1); | ||||
if (!MinByteSize.isPowerOfTwo()) { | if (!MinByteSize.isPowerOfTwo()) { | ||||
int MSB = (int)MinByteSize.getQuantity(); | int MSB = (int)MinByteSize.getQuantity(); | ||||
for (; MSB > 0; MSB /= 2) { | for (; MSB > 0; MSB /= 2) { | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |