GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — O2CodeChecker/aliceO2/SizeofCheck.cpp at master · AliceO2Group/O2CodeChecker

Expand file tree

/

SizeofCheck.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
49 lines (40 loc) · 1.39 KB
/

SizeofCheck.cpp

Copy path

File metadata and controls

49 lines (40 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//===--- SizeofCheck.cpp - clang-tidy--------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "SizeofCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
namespace aliceO2 {
void SizeofCheck::registerMatchers(MatchFinder *Finder) {
// matches sizeof + alignof
Finder->addMatcher(unaryExprOrTypeTraitExpr().bind("unaryexp"), this);
}
void SizeofCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Expr = Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("unaryexp");
const auto Kind = Expr->getKind();
if (Kind != UETT_SizeOf){
return;
}
// is argument of sizeof a Type?
if (Expr->isArgumentType()) {
diag(Expr->getBeginLoc(), "consider using sizeof() on instance instead on direct type");
return;
}
// we found a correct expression; check if it uses parens
if (dyn_cast<ParenExpr>(Expr->getArgumentExpr())) {
return;
}
// no parens -> issue warning
diag(Expr->getBeginLoc(), "consider using parens () for arguments to sizeof");
}
} // namespace aliceO2
} // namespace tidy
} // namespace clang
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.