PetScan::extract_conditional_assignment: extract write access as pet_expr
[pet.git] / clang.cc
bloba04e1114be64f59c7dcd686c1279318ae86a93e5
1 /*
2 * Copyright 2011 Leiden University. All rights reserved.
3 * Copyright 2013 Ecole Normale Superieure. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided
15 * with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY LEIDEN UNIVERSITY ''AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LEIDEN UNIVERSITY OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * The views and conclusions contained in the software and documentation
30 * are those of the authors and should not be interpreted as
31 * representing official policies, either expressed or implied, of
32 * Leiden University.
35 #include "clang.h"
37 using namespace clang;
39 /* Return the element type of the given array type.
41 QualType pet_clang_base_type(QualType qt)
43 const Type *type = qt.getTypePtr();
45 if (type->isPointerType())
46 return pet_clang_base_type(type->getPointeeType());
47 if (type->isArrayType()) {
48 const ArrayType *atype;
49 type = type->getCanonicalTypeInternal().getTypePtr();
50 atype = cast<ArrayType>(type);
51 return pet_clang_base_type(atype->getElementType());
53 return qt;
56 /* Given a record type, return the corresponding RecordDecl.
58 RecordDecl *pet_clang_record_decl(QualType T)
60 const Type *type = T->getCanonicalTypeInternal().getTypePtr();
61 const RecordType *record;
62 record = cast<RecordType>(type);
63 return record->getDecl();