aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-31 16:53:04 +0000
committerChris Lattner <sabre@nondot.org>2007-07-31 16:53:04 +0000
commitbefee48ff2a1dab236c5700f00ecca1cfdcd5837 (patch)
tree188d21b7dd78674599449ec2f72f1788afe379c3
parent11406c14282ae683fc5fa93a6aae49d53b214d3b (diff)
make isPointerType() a pure predicate, rename the
existing one to getAsPointerType() git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40639 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/Type.cpp5
-rw-r--r--Sema/SemaExpr.cpp8
-rw-r--r--clang.xcodeproj/project.pbxproj2
-rw-r--r--include/clang/AST/Type.h3
4 files changed, 11 insertions, 7 deletions
diff --git a/AST/Type.cpp b/AST/Type.cpp
index ecade56706..ae04c4effd 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -68,7 +68,10 @@ const FunctionType *Type::isFunctionType() const {
return 0;
}
-const PointerType *Type::isPointerType() const {
+// FIXME: move inline
+bool Type::isPointerType() const { return isa<PointerType>(CanonicalType); }
+
+const PointerType *Type::getAsPointerType() const {
// If this is directly a pointer type, return it.
if (const PointerType *PTy = dyn_cast<PointerType>(this))
return PTy;
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index a14482b454..89aef4ec59 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -303,12 +303,12 @@ ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
// and index from the expression types.
Expr *BaseExpr, *IndexExpr;
QualType ResultType;
- if (const PointerType *PTy = LHSTy->isPointerType()) {
+ if (const PointerType *PTy = LHSTy->getAsPointerType()) {
BaseExpr = LHSExp;
IndexExpr = RHSExp;
// FIXME: need to deal with const...
ResultType = PTy->getPointeeType();
- } else if (const PointerType *PTy = RHSTy->isPointerType()) {
+ } else if (const PointerType *PTy = RHSTy->getAsPointerType()) {
// Handle the uncommon case of "123[Ptr]".
BaseExpr = RHSExp;
IndexExpr = LHSExp;
@@ -409,7 +409,7 @@ ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
assert(!BaseType.isNull() && "no type for member expression");
if (OpKind == tok::arrow) {
- if (const PointerType *PT = BaseType->isPointerType())
+ if (const PointerType *PT = BaseType->getAsPointerType())
BaseType = PT->getPointeeType();
else
return Diag(OpLoc, diag::err_typecheck_member_reference_arrow,
@@ -1290,7 +1290,7 @@ QualType Sema::CheckIndirectionOperand(Expr *op, SourceLocation OpLoc) {
UsualUnaryConversions(op);
QualType qType = op->getType();
- if (const PointerType *PT = qType->isPointerType()) {
+ if (const PointerType *PT = qType->getAsPointerType()) {
QualType ptype = PT->getPointeeType();
// C99 6.5.3.2p4. "if it points to an object,...".
if (ptype->isIncompleteType()) { // An incomplete type is not an object
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index ff84ac7c23..bb772fa182 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -191,7 +191,7 @@
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = "<group>"; };
84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; };
- 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index fa6490364d..b35e19facc 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -240,7 +240,8 @@ public:
/// Derived types (C99 6.2.5p20).
bool isDerivedType() const;
const FunctionType *isFunctionType() const;
- const PointerType *isPointerType() const;
+ bool isPointerType() const;
+ const PointerType *getAsPointerType() const;
const ReferenceType *isReferenceType() const;
const ArrayType *isArrayType() const;
const RecordType *isRecordType() const;