summaryrefslogtreecommitdiff
path: root/clang-plugin/gvariant-checker.h
blob: 8cdb2bdb94b6235d655591ed87e23c6d4e47f02e (plain)
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
50
51
52
53
54
55
56
57
58
59
/* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
 * gnome-clang
 * Copyright © 2014 Philip Withnall
 *
 * gnome-clang is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * gnome-clang is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gnome-clang.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *     Philip Withnall <philip@tecnocode.co.uk>
 */

#ifndef GNOME_CLANG_GVARIANT_CHECKER_H
#define GNOME_CLANG_GVARIANT_CHECKER_H

#include <clang/AST/AST.h>
#include <clang/AST/ASTConsumer.h>
#include <clang/AST/RecursiveASTVisitor.h>
#include <clang/Frontend/CompilerInstance.h>

using namespace clang;

class GVariantVisitor : public RecursiveASTVisitor<GVariantVisitor> {
public:
	explicit GVariantVisitor (CompilerInstance& compiler) :
		_compiler (compiler), _context (compiler.getASTContext ()) {}

private:
	QualType _gvariant_pointer_type;
	CompilerInstance& _compiler;
	const ASTContext& _context;

public:
	bool VisitCallExpr (CallExpr* call);
};

class GVariantConsumer : public ASTConsumer {
public:
	GVariantConsumer (CompilerInstance& compiler) :
		_visitor (compiler) {}

private:
	GVariantVisitor _visitor;

public:
	virtual void HandleTranslationUnit (ASTContext& context);
};

#endif /* !GNOME_CLANG_GVARIANT_CHECKER_H */