summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-06-17 02:43:46 +0000
committerTed Kremenek <kremenek@apple.com>2008-06-17 02:43:46 +0000
commit08e171183ffe2039d5b071f89d3b16a0ca108d8b (patch)
tree91c727c8d7ec6a0d410ef031161a5d6c4fa5d0c8 /clang/lib/CodeGen/CodeGenFunction.h
parente47ca0940f2b3910fb1a464d8f35a68b04fba2ec (diff)
downloadbcm5719-llvm-08e171183ffe2039d5b071f89d3b16a0ca108d8b.tar.gz
bcm5719-llvm-08e171183ffe2039d5b071f89d3b16a0ca108d8b.zip
This patch is motivated by numerous strict-aliasing warnings when compiling
clang as a Release build. The big change is that all AST nodes (subclasses of Stmt) whose children are Expr* store their children as Stmt* or arrays of Stmt*. This is to remove strict-aliasing warnings when using StmtIterator. None of the interfaces of any of the classes have changed (except those with arg_iterators, see below), as the accessor methods introduce the needed casts (via cast<>). While this extra casting may seem cumbersome, it actually adds some important sanity checks throughout the codebase, as clients using StmtIterator can potentially overwrite children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts provide extra sanity checks that are operational in debug builds to catch invariant violations such as these. For classes that have arg_iterators (e.g., CallExpr), the definition of arg_iterator has been replaced. Instead of it being Expr**, it is an actual class (called ExprIterator) that wraps a Stmt**, and provides the necessary operators for iteration. The nice thing about this class is that it also uses cast<> to type-checking, which introduces extra sanity checks throughout the codebase that are useful for debugging. A few of the CodeGen functions that use arg_iterator (especially from OverloadExpr) have been modified to take begin and end iterators instead of a base Expr** and the number of arguments. This matches more with the abstraction of iteration. This still needs to be cleaned up a little bit, as clients expect that ExprIterator is a RandomAccessIterator (which we may or may not wish to allow for efficiency of representation). This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c, which was already broken) on both a Debug and Release build, but it should obviously be reviewed. llvm-svn: 52378
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h57
1 files changed, 11 insertions, 46 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 313d2d1829a..6712d2f05f1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -18,6 +18,9 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/IRBuilder.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprObjC.h"
+
#include <vector>
namespace llvm {
@@ -31,50 +34,7 @@ namespace clang {
class ObjCMethodDecl;
class TargetInfo;
class FunctionTypeProto;
-
- class Stmt;
- class CompoundStmt;
- class LabelStmt;
- class GotoStmt;
- class IfStmt;
- class WhileStmt;
- class DoStmt;
- class ForStmt;
- class ReturnStmt;
- class DeclStmt;
- class CaseStmt;
- class DefaultStmt;
- class SwitchStmt;
- class AsmStmt;
-
- class Expr;
- class DeclRefExpr;
- class StringLiteral;
- class IntegerLiteral;
- class FloatingLiteral;
- class CharacterLiteral;
- class TypesCompatibleExpr;
-
- class ImplicitCastExpr;
- class CastExpr;
- class CallExpr;
- class UnaryOperator;
- class BinaryOperator;
- class CompoundAssignOperator;
- class ArraySubscriptExpr;
- class ExtVectorElementExpr;
- class ConditionalOperator;
- class ChooseExpr;
- class PreDefinedExpr;
- class ObjCStringLiteral;
- class ObjCIvarRefExpr;
- class MemberExpr;
- class CompoundLiteralExpr;
-
- class VarDecl;
- class EnumConstantDecl;
- class ParmVarDecl;
- class FieldDecl;
+
namespace CodeGen {
class CodeGenModule;
class CodeGenTypes;
@@ -468,9 +428,14 @@ public:
//===--------------------------------------------------------------------===//
RValue EmitCallExpr(const CallExpr *E);
- RValue EmitCallExpr(Expr *FnExpr, Expr *const *Args, unsigned NumArgs);
+
+ RValue EmitCallExpr(Expr *FnExpr, CallExpr::const_arg_iterator ArgBeg,
+ CallExpr::const_arg_iterator ArgEnd);
+
RValue EmitCallExpr(llvm::Value *Callee, QualType FnType,
- Expr *const *Args, unsigned NumArgs);
+ CallExpr::const_arg_iterator ArgBeg,
+ CallExpr::const_arg_iterator ArgEnd);
+
RValue EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
OpenPOWER on IntegriCloud