2006-11-09 14:54:47 +08:00
|
|
|
//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2006-11-09 14:54:47 +08:00
|
|
|
// This file defines the Sema class, which performs semantic analysis and
|
|
|
|
// builds ASTs.
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-11-09 14:54:47 +08:00
|
|
|
#ifndef LLVM_CLANG_AST_SEMA_H
|
|
|
|
#define LLVM_CLANG_AST_SEMA_H
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2008-04-11 15:00:53 +08:00
|
|
|
#include "IdentifierResolver.h"
|
2008-07-01 18:37:29 +08:00
|
|
|
#include "CXXFieldCollector.h"
|
2008-10-22 00:13:35 +08:00
|
|
|
#include "SemaOverload.h"
|
2009-01-15 06:20:51 +08:00
|
|
|
#include "clang/AST/DeclBase.h"
|
2009-04-25 05:10:55 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2006-11-03 14:42:29 +08:00
|
|
|
#include "clang/Parse/Action.h"
|
2009-01-29 13:15:15 +08:00
|
|
|
#include "clang/Sema/SemaDiagnostic.h"
|
2007-07-22 15:07:56 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2007-10-06 02:00:57 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2007-10-07 09:13:46 +08:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2008-07-01 18:37:29 +08:00
|
|
|
#include "llvm/ADT/OwningPtr.h"
|
2009-01-16 08:38:09 +08:00
|
|
|
#include <string>
|
2008-10-24 12:54:22 +08:00
|
|
|
#include <vector>
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2007-08-23 13:46:52 +08:00
|
|
|
namespace llvm {
|
|
|
|
class APSInt;
|
|
|
|
}
|
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
namespace clang {
|
2006-11-10 14:20:45 +08:00
|
|
|
class ASTContext;
|
2008-02-06 08:46:58 +08:00
|
|
|
class ASTConsumer;
|
2006-11-03 14:42:29 +08:00
|
|
|
class Preprocessor;
|
|
|
|
class Decl;
|
2008-04-06 12:47:34 +08:00
|
|
|
class DeclContext;
|
2008-08-11 11:27:53 +08:00
|
|
|
class DeclSpec;
|
2009-04-25 05:10:55 +08:00
|
|
|
class ExternalSemaSource;
|
2008-04-02 07:04:06 +08:00
|
|
|
class NamedDecl;
|
2008-12-14 00:23:55 +08:00
|
|
|
class Stmt;
|
2007-04-03 06:55:05 +08:00
|
|
|
class Expr;
|
2007-09-02 23:34:30 +08:00
|
|
|
class InitListExpr;
|
2009-01-22 08:58:24 +08:00
|
|
|
class DesignatedInitExpr;
|
2007-12-28 13:29:59 +08:00
|
|
|
class CallExpr;
|
2009-01-06 13:10:23 +08:00
|
|
|
class DeclRefExpr;
|
2007-01-21 15:42:07 +08:00
|
|
|
class VarDecl;
|
2007-06-14 04:44:40 +08:00
|
|
|
class ParmVarDecl;
|
2007-01-28 03:27:06 +08:00
|
|
|
class TypedefDecl;
|
|
|
|
class FunctionDecl;
|
2007-04-06 06:36:20 +08:00
|
|
|
class QualType;
|
2009-03-07 20:16:37 +08:00
|
|
|
class LangOptions;
|
2007-07-21 00:59:19 +08:00
|
|
|
class Token;
|
2007-05-07 08:24:15 +08:00
|
|
|
class IntegerLiteral;
|
2008-01-22 08:55:40 +08:00
|
|
|
class StringLiteral;
|
2007-05-09 05:09:37 +08:00
|
|
|
class ArrayType;
|
2007-05-28 14:28:18 +08:00
|
|
|
class LabelStmt;
|
2007-07-22 15:07:56 +08:00
|
|
|
class SwitchStmt;
|
2009-04-28 05:33:24 +08:00
|
|
|
class CXXTryStmt;
|
2008-04-19 07:10:10 +08:00
|
|
|
class ExtVectorType;
|
2007-07-30 00:33:31 +08:00
|
|
|
class TypedefDecl;
|
2009-02-05 03:02:06 +08:00
|
|
|
class TemplateDecl;
|
Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,
template<> class vector<bool> { };
or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.
llvm-svn: 64716
2009-02-17 09:05:43 +08:00
|
|
|
class TemplateArgument;
|
2009-05-12 07:53:27 +08:00
|
|
|
class TemplateArgumentList;
|
2009-02-07 06:42:48 +08:00
|
|
|
class TemplateParameterList;
|
2009-02-10 07:23:08 +08:00
|
|
|
class TemplateTemplateParmDecl;
|
2009-02-26 06:02:03 +08:00
|
|
|
class ClassTemplateDecl;
|
2008-01-08 03:49:32 +08:00
|
|
|
class ObjCInterfaceDecl;
|
2008-04-02 07:04:06 +08:00
|
|
|
class ObjCCompatibleAliasDecl;
|
2008-01-08 03:49:32 +08:00
|
|
|
class ObjCProtocolDecl;
|
2009-03-01 08:56:52 +08:00
|
|
|
class ObjCImplDecl;
|
2008-01-08 03:49:32 +08:00
|
|
|
class ObjCImplementationDecl;
|
|
|
|
class ObjCCategoryImplDecl;
|
|
|
|
class ObjCCategoryDecl;
|
|
|
|
class ObjCIvarDecl;
|
|
|
|
class ObjCMethodDecl;
|
2008-05-01 08:03:38 +08:00
|
|
|
class ObjCPropertyDecl;
|
2009-01-09 01:28:14 +08:00
|
|
|
class ObjCContainerDecl;
|
2008-10-24 12:54:22 +08:00
|
|
|
class BasePaths;
|
2009-03-07 20:16:37 +08:00
|
|
|
struct MemberLookupCriteria;
|
2009-05-31 05:05:25 +08:00
|
|
|
class CXXTemporary;
|
2007-07-30 00:33:31 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// BlockSemaInfo - When a block is being parsed, this contains information
|
|
|
|
/// about the block. It is pointed to from Sema::CurBlock.
|
|
|
|
struct BlockSemaInfo {
|
|
|
|
llvm::SmallVector<ParmVarDecl*, 8> Params;
|
|
|
|
bool hasPrototype;
|
|
|
|
bool isVariadic;
|
|
|
|
bool hasBlockDeclRefExprs;
|
|
|
|
|
|
|
|
BlockDecl *TheDecl;
|
|
|
|
|
|
|
|
/// TheScope - This is the scope for the block itself, which contains
|
|
|
|
/// arguments etc.
|
|
|
|
Scope *TheScope;
|
|
|
|
|
|
|
|
/// ReturnType - This will get set to block result type, by looking at
|
|
|
|
/// return types, if any, in the block body.
|
|
|
|
Type *ReturnType;
|
|
|
|
|
|
|
|
/// LabelMap - This is a mapping from label identifiers to the LabelStmt for
|
|
|
|
/// it (which acts like the label decl in some ways). Forward referenced
|
|
|
|
/// labels have a LabelStmt created for them with a null location & SubStmt.
|
|
|
|
llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
|
|
|
|
|
2009-04-19 04:10:59 +08:00
|
|
|
/// SwitchStack - This is the current set of active switch statements in the
|
|
|
|
/// block.
|
|
|
|
llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
|
|
|
|
|
2009-04-19 13:28:12 +08:00
|
|
|
/// SavedFunctionNeedsScopeChecking - This is the value of
|
|
|
|
/// CurFunctionNeedsScopeChecking at the point when the block started.
|
|
|
|
bool SavedFunctionNeedsScopeChecking;
|
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// PrevBlockInfo - If this is nested inside another block, this points
|
|
|
|
/// to the outer block.
|
|
|
|
BlockSemaInfo *PrevBlockInfo;
|
|
|
|
};
|
|
|
|
|
2006-11-09 14:54:47 +08:00
|
|
|
/// Sema - This implements semantic analysis and AST building for C.
|
|
|
|
class Sema : public Action {
|
2009-02-17 08:58:30 +08:00
|
|
|
Sema(const Sema&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const Sema&); // DO NOT IMPLEMENT
|
2008-06-29 08:28:59 +08:00
|
|
|
public:
|
2009-01-23 03:21:44 +08:00
|
|
|
const LangOptions &LangOpts;
|
2007-02-28 09:22:02 +08:00
|
|
|
Preprocessor &PP;
|
2006-11-10 14:20:45 +08:00
|
|
|
ASTContext &Context;
|
2008-02-06 08:46:58 +08:00
|
|
|
ASTConsumer &Consumer;
|
2008-11-22 16:28:49 +08:00
|
|
|
Diagnostic &Diags;
|
|
|
|
SourceManager &SourceMgr;
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2009-04-25 05:10:55 +08:00
|
|
|
/// \brief Source of additional semantic information.
|
|
|
|
ExternalSemaSource *ExternalSource;
|
|
|
|
|
2008-06-28 14:07:14 +08:00
|
|
|
/// CurContext - This is the current declaration context of parsing.
|
2008-04-06 12:47:34 +08:00
|
|
|
DeclContext *CurContext;
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2008-11-09 01:17:31 +08:00
|
|
|
/// PreDeclaratorDC - Keeps the declaration context before switching to the
|
|
|
|
/// context of a declarator's nested-name-specifier.
|
|
|
|
DeclContext *PreDeclaratorDC;
|
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
/// CurBlock - If inside of a block definition, this contains a pointer to
|
|
|
|
/// the active block object that represents it.
|
|
|
|
BlockSemaInfo *CurBlock;
|
|
|
|
|
2008-10-14 13:35:18 +08:00
|
|
|
/// PackContext - Manages the stack for #pragma pack. An alignment
|
|
|
|
/// of 0 indicates default alignment.
|
2009-02-17 09:09:29 +08:00
|
|
|
void *PackContext; // Really a "PragmaPackStack*"
|
2008-10-14 13:35:18 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// FunctionLabelMap - This is a mapping from label identifiers to the
|
|
|
|
/// LabelStmt for it (which acts like the label decl in some ways). Forward
|
|
|
|
/// referenced labels have a LabelStmt created for them with a null location &
|
|
|
|
/// SubStmt.
|
|
|
|
///
|
|
|
|
/// Note that this should always be accessed through getLabelMap() in order
|
|
|
|
/// to handle blocks properly.
|
|
|
|
llvm::DenseMap<IdentifierInfo*, LabelStmt*> FunctionLabelMap;
|
2009-03-13 23:38:40 +08:00
|
|
|
|
2009-04-19 04:10:59 +08:00
|
|
|
/// FunctionSwitchStack - This is the current set of active switch statements
|
|
|
|
/// in the top level function. Clients should always use getSwitchStack() to
|
|
|
|
/// handle the case when they are in a block.
|
|
|
|
llvm::SmallVector<SwitchStmt*, 8> FunctionSwitchStack;
|
2009-05-18 02:41:29 +08:00
|
|
|
|
|
|
|
/// ExprTemporaries - This is the stack of temporaries that are created by
|
|
|
|
/// the current full expression.
|
2009-05-31 05:05:25 +08:00
|
|
|
llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries;
|
2009-05-18 02:41:29 +08:00
|
|
|
|
2009-04-19 13:21:20 +08:00
|
|
|
/// CurFunctionNeedsScopeChecking - This is set to true when a function or
|
|
|
|
/// ObjC method body contains a VLA or an ObjC try block, which introduce
|
|
|
|
/// scopes that need to be checked for goto conditions. If a function does
|
|
|
|
/// not contain this, then it need not have the jump checker run on it.
|
|
|
|
bool CurFunctionNeedsScopeChecking;
|
|
|
|
|
2008-04-19 07:10:10 +08:00
|
|
|
/// ExtVectorDecls - This is a list all the extended vector types. This allows
|
|
|
|
/// us to associate a raw vector type with one of the ext_vector type names.
|
2007-07-30 00:33:31 +08:00
|
|
|
/// This is only necessary for issuing pretty diagnostics.
|
2008-04-19 07:10:10 +08:00
|
|
|
llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
|
2007-08-11 04:18:51 +08:00
|
|
|
|
2008-09-28 22:55:53 +08:00
|
|
|
/// ObjCCategoryImpls - Maintain a list of category implementations so
|
|
|
|
/// we can check for duplicates and find local method declarations.
|
|
|
|
llvm::SmallVector<ObjCCategoryImplDecl*, 8> ObjCCategoryImpls;
|
|
|
|
|
2008-07-01 18:37:29 +08:00
|
|
|
/// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
|
|
|
|
llvm::OwningPtr<CXXFieldCollector> FieldCollector;
|
|
|
|
|
2009-03-23 04:18:17 +08:00
|
|
|
typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
|
|
|
|
|
|
|
|
/// PureVirtualClassDiagSet - a set of class declarations which we have
|
|
|
|
/// emitted a list of pure virtual functions. Used to prevent emitting the
|
|
|
|
/// same list more than once.
|
|
|
|
llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet;
|
|
|
|
|
2009-03-02 08:19:53 +08:00
|
|
|
/// \brief A mapping from external names to the most recent
|
|
|
|
/// locally-scoped external declaration with that name.
|
|
|
|
///
|
|
|
|
/// This map contains external declarations introduced in local
|
|
|
|
/// scoped, e.g.,
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// void f() {
|
|
|
|
/// void foo(int, int);
|
|
|
|
/// }
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// Here, the name "foo" will be associated with the declaration on
|
|
|
|
/// "foo" within f. This name is not visible outside of
|
|
|
|
/// "f". However, we still find it in two cases:
|
|
|
|
///
|
|
|
|
/// - If we are declaring another external with the name "foo", we
|
|
|
|
/// can find "foo" as a previous declaration, so that the types
|
|
|
|
/// of this external declaration can be checked for
|
|
|
|
/// compatibility.
|
|
|
|
///
|
|
|
|
/// - If we would implicitly declare "foo" (e.g., due to a call to
|
|
|
|
/// "foo" in C when no prototype or definition is visible), then
|
|
|
|
/// we find this declaration of "foo" and complain that it is
|
|
|
|
/// not visible.
|
|
|
|
llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls;
|
|
|
|
|
2009-04-22 01:11:58 +08:00
|
|
|
/// \brief The set of tentative declarations seen so far in this
|
|
|
|
/// translation unit for which no definition has been seen.
|
|
|
|
///
|
|
|
|
/// The tentative declarations are indexed by the name of the
|
|
|
|
/// declaration, and only the most recent tentative declaration for
|
|
|
|
/// a given variable will be recorded here.
|
|
|
|
llvm::DenseMap<DeclarationName, VarDecl *> TentativeDefinitions;
|
|
|
|
|
2008-04-11 15:00:53 +08:00
|
|
|
IdentifierResolver IdResolver;
|
|
|
|
|
2007-10-11 01:32:04 +08:00
|
|
|
/// Translation Unit Scope - useful to Objective-C actions that need
|
|
|
|
/// to lookup file scope declarations in the "ordinary" C decl namespace.
|
|
|
|
/// For example, user-defined classes, built-in "id" type, etc.
|
2007-10-10 06:01:59 +08:00
|
|
|
Scope *TUScope;
|
2008-11-11 19:37:55 +08:00
|
|
|
|
|
|
|
/// The C++ "std" namespace, where the standard library resides. Cached here
|
|
|
|
/// by GetStdNamespace
|
|
|
|
NamespaceDecl *StdNamespace;
|
2008-12-04 04:26:15 +08:00
|
|
|
|
|
|
|
/// A flag to remember whether the implicit forms of operator new and delete
|
|
|
|
/// have been declared.
|
|
|
|
bool GlobalNewDeleteDeclared;
|
2009-04-15 00:27:31 +08:00
|
|
|
|
|
|
|
/// \brief Whether the code handled by Sema should be considered a
|
|
|
|
/// complete translation unit or not.
|
|
|
|
///
|
|
|
|
/// When true (which is generally the case), Sema will perform
|
|
|
|
/// end-of-translation-unit semantic tasks (such as creating
|
|
|
|
/// initializers for tentative definitions in C) once parsing has
|
|
|
|
/// completed. This flag will be false when building PCH files,
|
|
|
|
/// since a PCH file is by definition not a complete translation
|
|
|
|
/// unit.
|
|
|
|
bool CompleteTranslationUnit;
|
|
|
|
|
2009-04-25 05:10:55 +08:00
|
|
|
typedef llvm::DenseMap<Selector, ObjCMethodList> MethodPool;
|
|
|
|
|
2007-10-14 08:58:41 +08:00
|
|
|
/// Instance/Factory Method Pools - allows efficient lookup when typechecking
|
|
|
|
/// messages to "id". We need to maintain a list, since selectors can have
|
|
|
|
/// differing signatures across classes. In Cocoa, this happens to be
|
|
|
|
/// extremely uncommon (only 1% of selectors are "overloaded").
|
2009-04-25 05:10:55 +08:00
|
|
|
MethodPool InstanceMethodPool;
|
|
|
|
MethodPool FactoryMethodPool;
|
2009-03-04 23:11:40 +08:00
|
|
|
|
2009-04-25 05:10:55 +08:00
|
|
|
MethodPool::iterator ReadMethodPool(Selector Sel, bool isInstance);
|
|
|
|
|
2009-03-04 23:11:40 +08:00
|
|
|
/// Private Helper predicate to check for 'self'.
|
|
|
|
bool isSelfExpr(Expr *RExpr);
|
2006-11-03 14:42:29 +08:00
|
|
|
public:
|
2009-04-15 00:27:31 +08:00
|
|
|
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
|
|
|
|
bool CompleteTranslationUnit = true);
|
2009-02-17 09:09:29 +08:00
|
|
|
~Sema() {
|
|
|
|
if (PackContext) FreePackedContext();
|
|
|
|
}
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2009-01-23 03:21:44 +08:00
|
|
|
const LangOptions &getLangOptions() const { return LangOpts; }
|
2008-11-22 16:28:49 +08:00
|
|
|
Diagnostic &getDiagnostics() const { return Diags; }
|
|
|
|
SourceManager &getSourceManager() const { return SourceMgr; }
|
|
|
|
|
2009-03-21 06:48:49 +08:00
|
|
|
/// \brief Helper class that creates diagnostics with optional
|
|
|
|
/// template instantiation stacks.
|
|
|
|
///
|
|
|
|
/// This class provides a wrapper around the basic DiagnosticBuilder
|
|
|
|
/// class that emits diagnostics. SemaDiagnosticBuilder is
|
|
|
|
/// responsible for emitting the diagnostic (as DiagnosticBuilder
|
|
|
|
/// does) and, if the diagnostic comes from inside a template
|
|
|
|
/// instantiation, printing the template instantiation stack as
|
|
|
|
/// well.
|
|
|
|
class SemaDiagnosticBuilder : public DiagnosticBuilder {
|
|
|
|
Sema &SemaRef;
|
|
|
|
unsigned DiagID;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
|
|
|
|
: DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
|
|
|
|
|
|
|
|
~SemaDiagnosticBuilder();
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Emit a diagnostic.
|
|
|
|
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
|
2009-03-11 02:03:33 +08:00
|
|
|
DiagnosticBuilder DB = Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID);
|
2009-03-21 06:48:49 +08:00
|
|
|
return SemaDiagnosticBuilder(DB, *this, DiagID);
|
2008-11-22 16:28:49 +08:00
|
|
|
}
|
2007-05-19 06:53:50 +08:00
|
|
|
|
2007-08-31 12:53:24 +08:00
|
|
|
virtual void DeleteExpr(ExprTy *E);
|
|
|
|
virtual void DeleteStmt(StmtTy *S);
|
|
|
|
|
2008-12-14 00:23:55 +08:00
|
|
|
OwningExprResult Owned(Expr* E) { return OwningExprResult(*this, E); }
|
2009-01-19 08:08:26 +08:00
|
|
|
OwningExprResult Owned(ExprResult R) {
|
2009-01-27 06:44:13 +08:00
|
|
|
if (R.isInvalid())
|
2009-01-22 06:32:33 +08:00
|
|
|
return ExprError();
|
2009-01-27 06:44:13 +08:00
|
|
|
return OwningExprResult(*this, R.get());
|
2009-01-19 08:08:26 +08:00
|
|
|
}
|
2008-12-14 00:23:55 +08:00
|
|
|
OwningStmtResult Owned(Stmt* S) { return OwningStmtResult(*this, S); }
|
|
|
|
|
2008-08-23 11:19:52 +08:00
|
|
|
virtual void ActOnEndOfTranslationUnit();
|
2009-01-20 06:31:54 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// getLabelMap() - Return the current label map. If we're in a block, we
|
|
|
|
/// return it.
|
|
|
|
llvm::DenseMap<IdentifierInfo*, LabelStmt*> &getLabelMap() {
|
|
|
|
return CurBlock ? CurBlock->LabelMap : FunctionLabelMap;
|
|
|
|
}
|
|
|
|
|
2009-04-19 04:10:59 +08:00
|
|
|
/// getSwitchStack - This is returns the switch stack for the current block or
|
|
|
|
/// function.
|
|
|
|
llvm::SmallVector<SwitchStmt*,8> &getSwitchStack() {
|
|
|
|
return CurBlock ? CurBlock->SwitchStack : FunctionSwitchStack;
|
|
|
|
}
|
|
|
|
|
2006-11-12 06:59:23 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Type Analysis / Processing: SemaType.cpp.
|
|
|
|
//
|
2009-03-24 07:06:20 +08:00
|
|
|
QualType adjustParameterType(QualType T);
|
2009-04-25 16:06:05 +08:00
|
|
|
QualType ConvertDeclSpecToType(const DeclSpec &DS, SourceLocation DeclLoc,
|
|
|
|
bool &IsInvalid);
|
2008-06-29 08:50:08 +08:00
|
|
|
void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL);
|
2009-02-28 08:25:32 +08:00
|
|
|
QualType BuildPointerType(QualType T, unsigned Quals,
|
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
2009-03-17 07:22:08 +08:00
|
|
|
QualType BuildReferenceType(QualType T, bool LValueRef, unsigned Quals,
|
2009-02-28 08:25:32 +08:00
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
|
|
|
QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
|
|
|
|
Expr *ArraySize, unsigned Quals,
|
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
2009-02-28 09:04:19 +08:00
|
|
|
QualType BuildFunctionType(QualType T,
|
|
|
|
QualType *ParamTypes, unsigned NumParamTypes,
|
|
|
|
bool Variadic, unsigned Quals,
|
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:
1) In C++, one is not allowed to define tag types within a type
specifier (e.g., static_cast<struct S { int x; } *>(0) is
ill-formed) or within the result or parameter types of a
function. We now diagnose this.
2) We can extend DeclGroups to contain information about any tags
that are declared/defined within the declaration specifiers of a
variable, e.g.,
struct Point { int x, y, z; } p;
This will help improve AST printing and template instantiation,
among other things.
3) For C99, we can keep track of whether a tag type is defined
within the type of a parameter, to properly cope with cases like,
e.g.,
int bar(struct T2 { int x; } y) {
struct T2 z;
}
We can also do similar things wherever there is a type specifier,
e.g., to keep track of where the definition of S occurs in this
legal C99 code:
(struct S { int x, y; } *)0
llvm-svn: 72555
2009-05-29 07:31:59 +08:00
|
|
|
QualType GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip = 0,
|
|
|
|
TagDecl **OwnedDecl = 0);
|
2008-11-18 06:58:34 +08:00
|
|
|
DeclarationName GetNameForDeclarator(Declarator &D);
|
2009-05-30 02:02:33 +08:00
|
|
|
bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range);
|
2009-05-29 23:01:05 +08:00
|
|
|
bool CheckDistantExceptionSpec(QualType T);
|
2008-11-18 06:58:34 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
QualType ObjCGetTypeForMethodDefinition(DeclPtrTy D);
|
2007-11-09 07:49:49 +08:00
|
|
|
|
2008-10-22 22:17:15 +08:00
|
|
|
bool UnwrapSimilarPointerTypes(QualType& T1, QualType& T2);
|
|
|
|
|
2008-12-02 22:43:59 +08:00
|
|
|
virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
|
2008-11-08 21:00:26 +08:00
|
|
|
|
2009-03-10 00:13:40 +08:00
|
|
|
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag,
|
2009-01-20 03:26:10 +08:00
|
|
|
SourceRange Range1 = SourceRange(),
|
|
|
|
SourceRange Range2 = SourceRange(),
|
|
|
|
QualType PrintType = QualType());
|
|
|
|
|
2009-03-19 08:39:20 +08:00
|
|
|
QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T);
|
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-11-10 13:29:30 +08:00
|
|
|
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
|
2006-11-03 14:42:29 +08:00
|
|
|
//
|
2009-03-05 09:25:28 +08:00
|
|
|
|
|
|
|
/// getDeclName - Return a pretty name for the specified decl if possible, or
|
|
|
|
/// an empty string if not. This is used for pretty crash reporting.
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual std::string getDeclName(DeclPtrTy D);
|
2009-03-05 09:25:28 +08:00
|
|
|
|
2009-03-30 00:50:03 +08:00
|
|
|
DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr);
|
|
|
|
|
2009-02-09 23:09:02 +08:00
|
|
|
virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
|
2009-02-05 01:00:24 +08:00
|
|
|
Scope *S, const CXXScopeSpec *SS);
|
2009-04-13 05:49:30 +08:00
|
|
|
virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
|
|
|
|
|
2009-03-30 00:50:03 +08:00
|
|
|
virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
|
|
|
|
return ActOnDeclarator(S, D, false);
|
2008-12-16 07:53:10 +08:00
|
|
|
}
|
2009-03-30 00:50:03 +08:00
|
|
|
DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D, bool IsFunctionDefinition);
|
2009-03-02 08:19:53 +08:00
|
|
|
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl,
|
|
|
|
Scope *S);
|
2009-04-08 03:37:57 +08:00
|
|
|
void DiagnoseFunctionSpecifiers(Declarator& D);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
2009-04-25 16:06:05 +08:00
|
|
|
QualType R, Decl* PrevDecl,
|
2009-02-17 01:45:42 +08:00
|
|
|
bool &Redeclaration);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
2009-04-25 16:06:05 +08:00
|
|
|
QualType R, NamedDecl* PrevDecl,
|
2009-02-17 01:45:42 +08:00
|
|
|
bool &Redeclaration);
|
2009-04-25 16:06:05 +08:00
|
|
|
void CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
|
2009-03-26 07:32:15 +08:00
|
|
|
bool &Redeclaration);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
2009-03-30 00:50:03 +08:00
|
|
|
QualType R, NamedDecl* PrevDecl,
|
2009-02-24 09:23:02 +08:00
|
|
|
bool IsFunctionDefinition,
|
2009-04-25 16:06:05 +08:00
|
|
|
bool &Redeclaration);
|
|
|
|
void CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
|
2009-03-24 07:06:20 +08:00
|
|
|
bool &Redeclaration,
|
|
|
|
bool &OverloadableAttrRequired);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D);
|
|
|
|
virtual void ActOnParamDefaultArgument(DeclPtrTy param,
|
2008-04-08 12:40:51 +08:00
|
|
|
SourceLocation EqualLoc,
|
2009-03-16 01:47:39 +08:00
|
|
|
ExprArg defarg);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
|
2008-12-24 08:01:03 +08:00
|
|
|
SourceLocation EqualLoc);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnParamDefaultArgumentError(DeclPtrTy param);
|
2009-05-31 05:37:25 +08:00
|
|
|
virtual void AddInitializerToDecl(DeclPtrTy dcl, FullExprArg init);
|
2009-03-29 03:18:32 +08:00
|
|
|
void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit);
|
|
|
|
void ActOnUninitializedDecl(DeclPtrTy dcl);
|
|
|
|
virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc);
|
2009-05-29 09:49:24 +08:00
|
|
|
virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
|
|
|
|
DeclPtrTy *Group,
|
2009-03-30 00:50:03 +08:00
|
|
|
unsigned NumDecls);
|
2009-04-02 07:51:29 +08:00
|
|
|
virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
|
|
|
|
SourceLocation LocAfterDecls);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, Declarator &D);
|
|
|
|
virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, DeclPtrTy D);
|
|
|
|
virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclPtrTy D);
|
2009-01-20 06:31:54 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body);
|
2009-05-16 01:59:04 +08:00
|
|
|
DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body,
|
|
|
|
bool IsInstantiation);
|
2009-04-19 12:46:21 +08:00
|
|
|
void DiagnoseInvalidJumps(Stmt *Body);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
|
2008-02-08 08:33:21 +08:00
|
|
|
|
2007-10-10 06:01:59 +08:00
|
|
|
/// Scope actions.
|
|
|
|
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
|
|
|
|
virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
|
2007-01-28 03:27:06 +08:00
|
|
|
|
2006-11-19 10:43:37 +08:00
|
|
|
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
|
|
|
|
/// no declarator (e.g. "struct foo;") is parsed.
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
|
2006-11-19 10:43:37 +08:00
|
|
|
|
2009-01-07 08:43:41 +08:00
|
|
|
bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
|
|
|
|
RecordDecl *AnonRecord);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
|
|
|
RecordDecl *Record);
|
2009-01-07 08:43:41 +08:00
|
|
|
|
2009-05-15 00:41:31 +08:00
|
|
|
bool isAcceptableTagRedeclaration(const TagDecl *Previous,
|
|
|
|
TagDecl::TagKind NewTag,
|
|
|
|
SourceLocation NewTagLoc,
|
|
|
|
const IdentifierInfo &Name);
|
2009-05-04 01:18:57 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
|
|
|
|
SourceLocation KWLoc, const CXXScopeSpec &SS,
|
|
|
|
IdentifierInfo *Name, SourceLocation NameLoc,
|
When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:
1) In C++, one is not allowed to define tag types within a type
specifier (e.g., static_cast<struct S { int x; } *>(0) is
ill-formed) or within the result or parameter types of a
function. We now diagnose this.
2) We can extend DeclGroups to contain information about any tags
that are declared/defined within the declaration specifiers of a
variable, e.g.,
struct Point { int x, y, z; } p;
This will help improve AST printing and template instantiation,
among other things.
3) For C99, we can keep track of whether a tag type is defined
within the type of a parameter, to properly cope with cases like,
e.g.,
int bar(struct T2 { int x; } y) {
struct T2 z;
}
We can also do similar things wherever there is a type specifier,
e.g., to keep track of where the definition of S occurs in this
legal C99 code:
(struct S { int x, y; } *)0
llvm-svn: 72555
2009-05-29 07:31:59 +08:00
|
|
|
AttributeList *Attr, AccessSpecifier AS,
|
|
|
|
bool &OwnedDecl);
|
Change struct forward declarations and definitions to use unique RecordDecls, as opposed to creating a single RecordDecl and reusing it.
This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet).
The motivation of this patch is as follows:
- Capture more source information, necessary for refactoring/rewriting clients.
- Pave the way to resolve ownership issues with RecordDecls with the forthcoming
addition of DeclGroups.
Current caveats:
- Until DeclGroups are in place, we will leak RecordDecls not explicitly
referenced by the AST. For example:
typedef struct { ... } x;
The RecordDecl for the struct will be leaked because the TypedefDecl doesn't
refer to it. This will be solved with DeclGroups.
- This patch also (temporarily) breaks CodeGen. More below.
High-level changes:
- As before, TagType still refers to a TagDecl, but it doesn't own it. When
a struct/union/class is first referenced, a RecordType and RecordDecl are
created for it, and the RecordType refers to that RecordDecl. Later, if
a new RecordDecl is created, the pointer to a RecordDecl in RecordType is
updated to point to the RecordDecl that defines the struct/union/class.
- TagDecl and RecordDecl now how a method 'getDefinition()' to return the
TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular
enum/struct/class/union. This is useful from going from a RecordDecl* that
defines a forward declaration to the RecordDecl* that provides the actual
definition. Note that this also works for EnumDecls, except that in this case
there is no distinction between forward declarations and definitions (yet).
- Clients should no longer assume that 'isDefinition()' returns true from a
RecordDecl if the corresponding struct/union/class has been defined.
isDefinition() only returns true if a particular RecordDecl is the defining
Decl. Use 'getDefinition()' instead to determine if a struct has been defined.
- The main changes to Sema happen in ActOnTag. To make the changes more
incremental, I split off the processing of enums and structs et al into two
code paths. Enums use the original code path (which is in ActOnTag) and
structs use the ActOnTagStruct. Eventually the two code paths will be merged,
but the idea was to preserve the original logic both for comparison and not to
change the logic for both enums and structs all at once.
- There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls
that correspond to the same type simply have a pointer to that type. If we
need to figure out what are all the RecordDecls for a given type we can build
a backmap.
- The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the
changes to RecordDecl. For some reason 'svn' marks the entire file as changed.
Why is CodeGen broken:
- Codegen assumes that there is an equivalence between RecordDecl* and
RecordType*. This was true before because we only created one RecordDecl* for
a given RecordType*, but it is no longer true. I believe this shouldn't be too
hard to change, but the patch was big enough as it is.
I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C).
llvm-svn: 55839
2008-09-06 01:16:31 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
|
2008-08-23 10:00:52 +08:00
|
|
|
IdentifierInfo *ClassName,
|
2009-03-29 03:18:32 +08:00
|
|
|
llvm::SmallVectorImpl<DeclPtrTy> &Decls);
|
|
|
|
virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
|
|
|
|
SourceLocation DeclStart,
|
|
|
|
Declarator &D, ExprTy *BitfieldWidth);
|
2009-03-06 06:45:59 +08:00
|
|
|
|
|
|
|
FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
|
2009-03-12 04:50:30 +08:00
|
|
|
Declarator &D, Expr *BitfieldWidth,
|
|
|
|
AccessSpecifier AS);
|
2009-03-06 06:45:59 +08:00
|
|
|
|
2009-03-12 02:59:21 +08:00
|
|
|
FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
|
|
|
|
RecordDecl *Record, SourceLocation Loc,
|
|
|
|
bool Mutable, Expr *BitfieldWidth,
|
2009-03-12 04:50:30 +08:00
|
|
|
AccessSpecifier AS, NamedDecl *PrevDecl,
|
2009-03-12 02:59:21 +08:00
|
|
|
Declarator *D = 0);
|
2008-04-11 07:32:45 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
|
|
|
|
Declarator &D, ExprTy *BitfieldWidth,
|
|
|
|
tok::ObjCKeywordKind visibility);
|
2008-04-11 07:32:45 +08:00
|
|
|
|
2007-09-15 07:09:53 +08:00
|
|
|
// This is used for both record definitions and ObjC interface declarations.
|
2007-09-29 08:54:24 +08:00
|
|
|
virtual void ActOnFields(Scope* S,
|
2009-03-29 03:18:32 +08:00
|
|
|
SourceLocation RecLoc, DeclPtrTy TagDecl,
|
|
|
|
DeclPtrTy *Fields, unsigned NumFields,
|
2008-10-03 10:03:53 +08:00
|
|
|
SourceLocation LBrac, SourceLocation RBrac,
|
|
|
|
AttributeList *AttrList);
|
Unify the code for defining tags in C and C++, so that we always
introduce a Scope for the body of a tag. This reduces the number of
semantic differences between C and C++ structs and unions, and will
help with other features (e.g., anonymous unions) in C. Some important
points:
- Fields are now in the "member" namespace (IDNS_Member), to keep
them separate from tags and ordinary names in C. See the new test
in Sema/member-reference.c for an example of why this matters. In
C++, ordinary and member name lookup will find members in both the
ordinary and member namespace, so the difference between
IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
only in C++!).
- We always introduce a Scope and push a DeclContext when we're
defining a tag, in both C and C++. Previously, we had different
actions and different Scope/CurContext behavior for enums, C
structs/unions, and C++ structs/unions/classes. Now, it's one pair
of actions. (Yay!)
There's still some fuzziness in the handling of struct/union/enum
definitions within other struct/union/enum definitions in C. We'll
need to do some more cleanup to eliminate some reliance on CurContext
before we can solve this issue for real. What we want is for something
like this:
struct X {
struct T { int x; } t;
};
to introduce T into translation unit scope (placing it at the
appropriate point in the IdentifierResolver chain, too), but it should
still have struct X as its lexical declaration
context. PushOnScopeChains isn't smart enough to do that yet, though,
so there's a FIXME test in nested-redef.c
llvm-svn: 61940
2009-01-09 04:45:30 +08:00
|
|
|
|
|
|
|
/// ActOnTagStartDefinition - Invoked when we have entered the
|
|
|
|
/// scope of a tag's definition (e.g., for an enumeration, class,
|
|
|
|
/// struct, or union).
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl);
|
Unify the code for defining tags in C and C++, so that we always
introduce a Scope for the body of a tag. This reduces the number of
semantic differences between C and C++ structs and unions, and will
help with other features (e.g., anonymous unions) in C. Some important
points:
- Fields are now in the "member" namespace (IDNS_Member), to keep
them separate from tags and ordinary names in C. See the new test
in Sema/member-reference.c for an example of why this matters. In
C++, ordinary and member name lookup will find members in both the
ordinary and member namespace, so the difference between
IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
only in C++!).
- We always introduce a Scope and push a DeclContext when we're
defining a tag, in both C and C++. Previously, we had different
actions and different Scope/CurContext behavior for enums, C
structs/unions, and C++ structs/unions/classes. Now, it's one pair
of actions. (Yay!)
There's still some fuzziness in the handling of struct/union/enum
definitions within other struct/union/enum definitions in C. We'll
need to do some more cleanup to eliminate some reliance on CurContext
before we can solve this issue for real. What we want is for something
like this:
struct X {
struct T { int x; } t;
};
to introduce T into translation unit scope (placing it at the
appropriate point in the IdentifierResolver chain, too), but it should
still have struct X as its lexical declaration
context. PushOnScopeChains isn't smart enough to do that yet, though,
so there's a FIXME test in nested-redef.c
llvm-svn: 61940
2009-01-09 04:45:30 +08:00
|
|
|
|
|
|
|
/// ActOnTagFinishDefinition - Invoked once we have finished parsing
|
|
|
|
/// the definition of a tag (enumeration, class, struct, or union).
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl);
|
Unify the code for defining tags in C and C++, so that we always
introduce a Scope for the body of a tag. This reduces the number of
semantic differences between C and C++ structs and unions, and will
help with other features (e.g., anonymous unions) in C. Some important
points:
- Fields are now in the "member" namespace (IDNS_Member), to keep
them separate from tags and ordinary names in C. See the new test
in Sema/member-reference.c for an example of why this matters. In
C++, ordinary and member name lookup will find members in both the
ordinary and member namespace, so the difference between
IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
only in C++!).
- We always introduce a Scope and push a DeclContext when we're
defining a tag, in both C and C++. Previously, we had different
actions and different Scope/CurContext behavior for enums, C
structs/unions, and C++ structs/unions/classes. Now, it's one pair
of actions. (Yay!)
There's still some fuzziness in the handling of struct/union/enum
definitions within other struct/union/enum definitions in C. We'll
need to do some more cleanup to eliminate some reliance on CurContext
before we can solve this issue for real. What we want is for something
like this:
struct X {
struct T { int x; } t;
};
to introduce T into translation unit scope (placing it at the
appropriate point in the IdentifierResolver chain, too), but it should
still have struct X as its lexical declaration
context. PushOnScopeChains isn't smart enough to do that yet, though,
so there's a FIXME test in nested-redef.c
llvm-svn: 61940
2009-01-09 04:45:30 +08:00
|
|
|
|
2009-03-18 03:05:46 +08:00
|
|
|
EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
|
|
|
|
EnumConstantDecl *LastEnumConst,
|
|
|
|
SourceLocation IdLoc,
|
|
|
|
IdentifierInfo *Id,
|
|
|
|
ExprArg val);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
|
|
|
|
DeclPtrTy LastEnumConstant,
|
|
|
|
SourceLocation IdLoc, IdentifierInfo *Id,
|
|
|
|
SourceLocation EqualLoc, ExprTy *Val);
|
2009-05-16 15:06:02 +08:00
|
|
|
virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
|
|
|
|
SourceLocation RBraceLoc, DeclPtrTy EnumDecl,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy *Elements, unsigned NumElements);
|
2008-11-08 21:00:26 +08:00
|
|
|
|
2008-11-09 01:17:31 +08:00
|
|
|
DeclContext *getContainingDC(DeclContext *DC);
|
2008-07-01 18:37:29 +08:00
|
|
|
|
2008-04-04 14:12:32 +08:00
|
|
|
/// Set the current declaration context until it gets popped.
|
2008-12-12 00:49:14 +08:00
|
|
|
void PushDeclContext(Scope *S, DeclContext *DC);
|
2008-04-06 12:47:34 +08:00
|
|
|
void PopDeclContext();
|
2008-06-28 14:07:14 +08:00
|
|
|
|
2008-12-05 07:50:19 +08:00
|
|
|
/// getCurFunctionDecl - If inside of a function body, this returns a pointer
|
|
|
|
/// to the function decl for the function being parsed. If we're currently
|
|
|
|
/// in a 'block', this returns the containing context.
|
|
|
|
FunctionDecl *getCurFunctionDecl();
|
|
|
|
|
|
|
|
/// getCurMethodDecl - If inside of a method body, this returns a pointer to
|
|
|
|
/// the method decl for the method being parsed. If we're currently
|
|
|
|
/// in a 'block', this returns the containing context.
|
2008-08-11 13:35:13 +08:00
|
|
|
ObjCMethodDecl *getCurMethodDecl();
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2008-12-05 07:50:19 +08:00
|
|
|
/// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
|
|
|
|
/// or C function we're in, otherwise return null. If we're currently
|
|
|
|
/// in a 'block', this returns the containing context.
|
|
|
|
NamedDecl *getCurFunctionOrMethodDecl();
|
|
|
|
|
2008-04-12 08:47:19 +08:00
|
|
|
/// Add this decl to the scope shadowed decl chains.
|
|
|
|
void PushOnScopeChains(NamedDecl *D, Scope *S);
|
|
|
|
|
2008-09-10 05:18:04 +08:00
|
|
|
/// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
|
|
|
|
/// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
|
|
|
|
/// true if 'D' belongs to the given declaration context.
|
|
|
|
bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S = 0) {
|
2008-12-12 00:49:14 +08:00
|
|
|
return IdResolver.isDeclInScope(D, Ctx, Context, S);
|
2008-09-10 05:18:04 +08:00
|
|
|
}
|
|
|
|
|
Start of checking for gotos which jump to an illegal destination.
As far as I know, this catches all cases of jumping into the scope of a
variable with a variably modified type (excluding statement
expressions) in C. This is missing some stuff we probably want to check
(other kinds of variably modified declarations, statement expressions,
indirect gotos/addresses of labels in a scope, ObjC @try/@finally, cleanup
attribute), the diagnostics aren't very good, and it's not particularly
efficient, but it's a decent start.
This patch is a slightly modified version of the patch I attached to
PR3259, and it fixes that bug. I was sort of planning on improving
it, but I think it's okay as-is, especially since it looks like CodeGen
doesn't have any use for this sort of data structure. The only
significant change I can think of from the version I attached to PR3259
is that this version skips running the checking code when a function
doesn't contain any labels.
This patch doesn't cover case statements, which also need similar
checking; I'm not sure how we should deal with that. Extending the goto
checking to also check case statements wouldn't be too hard; it's just a
matter of keeping track of the scope of the closest switch and checking that
the scope of every case is the same as the scope of the switch. That said,
it would likely be a performance hit to run this check on every
function (it's an extra pass over the entire function), so we probably want
some other solution.
llvm-svn: 65678
2009-02-28 13:41:13 +08:00
|
|
|
|
2008-02-21 09:07:18 +08:00
|
|
|
/// Subroutines of ActOnDeclarator().
|
2009-03-30 00:50:03 +08:00
|
|
|
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T);
|
2009-04-25 16:06:05 +08:00
|
|
|
void MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
|
2009-02-17 01:45:42 +08:00
|
|
|
bool MergeFunctionDecl(FunctionDecl *New, Decl *Old);
|
2009-02-24 09:23:02 +08:00
|
|
|
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old);
|
2009-04-25 16:06:05 +08:00
|
|
|
void MergeVarDecl(VarDecl *New, Decl *Old);
|
2009-02-17 01:45:42 +08:00
|
|
|
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
|
2008-10-22 00:13:35 +08:00
|
|
|
|
|
|
|
/// C++ Overloading.
|
|
|
|
bool IsOverload(FunctionDecl *New, Decl* OldD,
|
|
|
|
OverloadedFunctionDecl::function_iterator &MatchedDecl);
|
2008-11-04 03:09:14 +08:00
|
|
|
ImplicitConversionSequence
|
|
|
|
TryImplicitConversion(Expr* From, QualType ToType,
|
2009-01-14 23:45:31 +08:00
|
|
|
bool SuppressUserConversions = false,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool AllowExplicit = false,
|
|
|
|
bool ForceRValue = false);
|
2008-11-01 00:23:19 +08:00
|
|
|
bool IsStandardConversion(Expr *From, QualType ToType,
|
|
|
|
StandardConversionSequence& SCS);
|
2008-10-22 00:13:35 +08:00
|
|
|
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
|
|
|
|
bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
|
2009-02-12 08:15:05 +08:00
|
|
|
bool IsComplexPromotion(QualType FromType, QualType ToType);
|
2008-10-22 00:13:35 +08:00
|
|
|
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
|
2008-12-20 01:40:08 +08:00
|
|
|
QualType& ConvertedType, bool &IncompatibleObjC);
|
2008-12-20 03:13:09 +08:00
|
|
|
bool isObjCPointerConversion(QualType FromType, QualType ToType,
|
|
|
|
QualType& ConvertedType, bool &IncompatibleObjC);
|
2008-10-24 12:54:22 +08:00
|
|
|
bool CheckPointerConversion(Expr *From, QualType ToType);
|
2009-01-26 03:43:20 +08:00
|
|
|
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
|
|
|
|
QualType &ConvertedType);
|
|
|
|
bool CheckMemberPointerConversion(Expr *From, QualType ToType);
|
2008-10-22 07:43:52 +08:00
|
|
|
bool IsQualificationConversion(QualType FromType, QualType ToType);
|
2008-11-01 00:23:19 +08:00
|
|
|
bool IsUserDefinedConversion(Expr *From, QualType ToType,
|
2009-01-14 23:45:31 +08:00
|
|
|
UserDefinedConversionSequence& User,
|
2009-01-31 07:27:23 +08:00
|
|
|
bool AllowConversionFunctions,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool AllowExplicit, bool ForceRValue);
|
2008-10-22 00:13:35 +08:00
|
|
|
|
|
|
|
ImplicitConversionSequence::CompareKind
|
|
|
|
CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
|
|
|
|
const ImplicitConversionSequence& ICS2);
|
|
|
|
|
|
|
|
ImplicitConversionSequence::CompareKind
|
|
|
|
CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
|
|
|
|
const StandardConversionSequence& SCS2);
|
|
|
|
|
2008-10-22 22:17:15 +08:00
|
|
|
ImplicitConversionSequence::CompareKind
|
|
|
|
CompareQualificationConversions(const StandardConversionSequence& SCS1,
|
|
|
|
const StandardConversionSequence& SCS2);
|
|
|
|
|
2008-10-23 08:40:37 +08:00
|
|
|
ImplicitConversionSequence::CompareKind
|
|
|
|
CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
|
|
|
|
const StandardConversionSequence& SCS2);
|
|
|
|
|
2008-11-04 03:09:14 +08:00
|
|
|
ImplicitConversionSequence
|
|
|
|
TryCopyInitialization(Expr* From, QualType ToType,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool SuppressUserConversions = false,
|
|
|
|
bool ForceRValue = false);
|
2008-10-29 08:13:59 +08:00
|
|
|
bool PerformCopyInitialization(Expr *&From, QualType ToType,
|
2009-04-13 01:16:29 +08:00
|
|
|
const char *Flavor, bool Elidable = false);
|
2008-10-29 08:13:59 +08:00
|
|
|
|
2008-11-19 07:14:02 +08:00
|
|
|
ImplicitConversionSequence
|
|
|
|
TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method);
|
|
|
|
bool PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method);
|
|
|
|
|
2009-01-14 23:45:31 +08:00
|
|
|
ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
|
|
|
|
bool PerformContextuallyConvertToBool(Expr *&From);
|
|
|
|
|
2008-10-22 00:13:35 +08:00
|
|
|
/// OverloadingResult - Capture the result of performing overload
|
|
|
|
/// resolution.
|
|
|
|
enum OverloadingResult {
|
|
|
|
OR_Success, ///< Overload resolution succeeded.
|
|
|
|
OR_No_Viable_Function, ///< No viable function found.
|
2009-02-19 05:56:37 +08:00
|
|
|
OR_Ambiguous, ///< Ambiguous candidates found.
|
|
|
|
OR_Deleted ///< Overload resoltuion refers to a deleted function.
|
2008-10-22 00:13:35 +08:00
|
|
|
};
|
|
|
|
|
2009-03-14 02:40:31 +08:00
|
|
|
typedef llvm::SmallPtrSet<FunctionDecl *, 16> FunctionSet;
|
|
|
|
typedef llvm::SmallPtrSet<NamespaceDecl *, 16> AssociatedNamespaceSet;
|
|
|
|
typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
|
|
|
|
|
2008-10-22 00:13:35 +08:00
|
|
|
void AddOverloadCandidate(FunctionDecl *Function,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2008-11-04 03:09:14 +08:00
|
|
|
OverloadCandidateSet& CandidateSet,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool SuppressUserConversions = false,
|
|
|
|
bool ForceRValue = false);
|
2009-03-14 02:40:31 +08:00
|
|
|
void AddFunctionCandidates(const FunctionSet &Functions,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversions = false);
|
2008-11-19 07:14:02 +08:00
|
|
|
void AddMethodCandidate(CXXMethodDecl *Method,
|
|
|
|
Expr *Object, Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool SuppressUserConversions = false,
|
|
|
|
bool ForceRValue = false);
|
2008-11-08 06:36:19 +08:00
|
|
|
void AddConversionCandidate(CXXConversionDecl *Conversion,
|
|
|
|
Expr *From, QualType ToType,
|
|
|
|
OverloadCandidateSet& CandidateSet);
|
2008-11-20 06:57:39 +08:00
|
|
|
void AddSurrogateCandidate(CXXConversionDecl *Conversion,
|
2009-02-27 07:50:07 +08:00
|
|
|
const FunctionProtoType *Proto,
|
2008-11-20 06:57:39 +08:00
|
|
|
Expr *Object, Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet);
|
2009-03-14 02:40:31 +08:00
|
|
|
void AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S,
|
2009-02-05 00:44:47 +08:00
|
|
|
SourceLocation OpLoc,
|
2008-11-19 07:14:02 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-02-05 00:44:47 +08:00
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
SourceRange OpRange = SourceRange());
|
2009-03-14 02:40:31 +08:00
|
|
|
void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
SourceRange OpRange = SourceRange());
|
Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin
bool operator==(int const*, int const*)
can be used for the expression "x1 == x2" given:
struct X {
operator int const*();
} x1, x2;
The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it.
There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.
Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.
As part of this change, ImplicitCastExpr can now be an lvalue.
llvm-svn: 59148
2008-11-13 01:17:38 +08:00
|
|
|
void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-01-13 08:52:54 +08:00
|
|
|
OverloadCandidateSet& CandidateSet,
|
2009-01-14 23:45:31 +08:00
|
|
|
bool IsAssignmentOperator = false,
|
|
|
|
unsigned NumContextualBoolArguments = 0);
|
2008-11-19 23:42:04 +08:00
|
|
|
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet);
|
2009-02-04 08:32:51 +08:00
|
|
|
void AddArgumentDependentLookupCandidates(DeclarationName Name,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet);
|
2008-10-22 00:13:35 +08:00
|
|
|
bool isBetterOverloadCandidate(const OverloadCandidate& Cand1,
|
|
|
|
const OverloadCandidate& Cand2);
|
|
|
|
OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet,
|
|
|
|
OverloadCandidateSet::iterator& Best);
|
|
|
|
void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
|
|
|
|
bool OnlyViable);
|
|
|
|
|
2008-11-11 04:40:00 +08:00
|
|
|
FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
|
|
|
|
bool Complain);
|
|
|
|
void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn);
|
|
|
|
|
2009-02-04 23:01:18 +08:00
|
|
|
FunctionDecl *ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee,
|
|
|
|
DeclarationName UnqualifiedName,
|
2008-11-26 14:01:48 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
2009-02-04 08:32:51 +08:00
|
|
|
SourceLocation RParenLoc,
|
2009-02-04 23:01:18 +08:00
|
|
|
bool &ArgumentDependentLookup);
|
2009-03-14 02:40:31 +08:00
|
|
|
|
2009-03-14 07:49:33 +08:00
|
|
|
OwningExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
|
|
|
|
unsigned Opc,
|
|
|
|
FunctionSet &Functions,
|
|
|
|
ExprArg input);
|
|
|
|
|
2009-03-14 02:40:31 +08:00
|
|
|
OwningExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
|
|
|
|
unsigned Opc,
|
|
|
|
FunctionSet &Functions,
|
|
|
|
Expr *LHS, Expr *RHS);
|
|
|
|
|
2008-12-22 13:46:06 +08:00
|
|
|
ExprResult
|
|
|
|
BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
|
|
|
|
SourceLocation LParenLoc, Expr **Args,
|
|
|
|
unsigned NumArgs, SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
2008-11-20 05:05:33 +08:00
|
|
|
ExprResult
|
2008-12-06 08:22:45 +08:00
|
|
|
BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
|
2008-11-20 05:05:33 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
2008-10-22 00:13:35 +08:00
|
|
|
|
2008-12-23 08:26:44 +08:00
|
|
|
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
|
2008-11-21 00:27:02 +08:00
|
|
|
SourceLocation MemberLoc,
|
|
|
|
IdentifierInfo &Member);
|
2009-01-14 23:45:31 +08:00
|
|
|
|
2009-01-06 15:27:21 +08:00
|
|
|
/// Helpers for dealing with function parameters.
|
2008-04-08 12:40:51 +08:00
|
|
|
bool CheckParmsForFunctionDef(FunctionDecl *FD);
|
|
|
|
void CheckCXXDefaultArguments(FunctionDecl *FD);
|
2008-05-07 12:49:29 +08:00
|
|
|
void CheckExtraCXXDefaultArguments(Declarator &D);
|
2007-03-16 08:33:25 +08:00
|
|
|
|
2009-01-13 02:45:55 +08:00
|
|
|
Scope *getNonFieldDeclScope(Scope *S);
|
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
/// \name Name lookup
|
|
|
|
///
|
|
|
|
/// These routines provide name lookup that is used during semantic
|
|
|
|
/// analysis to resolve the various kinds of names (identifiers,
|
|
|
|
/// overloaded operator names, constructor names, etc.) into zero or
|
|
|
|
/// more declarations within a particular scope. The major entry
|
|
|
|
/// points are LookupName, which performs unqualified name lookup,
|
|
|
|
/// and LookupQualifiedName, which performs qualified name lookup.
|
|
|
|
///
|
|
|
|
/// All name lookup is performed based on some specific criteria,
|
|
|
|
/// which specify what names will be visible to name lookup and how
|
|
|
|
/// far name lookup should work. These criteria are important both
|
|
|
|
/// for capturing language semantics (certain lookups will ignore
|
|
|
|
/// certain names, for example) and for performance, since name
|
|
|
|
/// lookup is often a bottleneck in the compilation of C++. Name
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
/// lookup criteria is specified via the LookupCriteria enumeration.
|
2009-01-15 06:20:51 +08:00
|
|
|
///
|
|
|
|
/// The results of name lookup can vary based on the kind of name
|
|
|
|
/// lookup performed, the current language, and the translation
|
|
|
|
/// unit. In C, for example, name lookup will either return nothing
|
|
|
|
/// (no entity found) or a single declaration. In C++, name lookup
|
|
|
|
/// can additionally refer to a set of overloaded functions or
|
|
|
|
/// result in an ambiguity. All of the possible results of name
|
|
|
|
/// lookup are captured by the LookupResult class, which provides
|
|
|
|
/// the ability to distinguish among them.
|
|
|
|
//@{
|
|
|
|
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
/// @brief Describes the kind of name lookup to perform.
|
|
|
|
enum LookupNameKind {
|
|
|
|
/// Ordinary name lookup, which finds ordinary names (functions,
|
|
|
|
/// variables, typedefs, etc.) in C and most kinds of names
|
|
|
|
/// (functions, variables, members, types, etc.) in C++.
|
|
|
|
LookupOrdinaryName = 0,
|
|
|
|
/// Tag name lookup, which finds the names of enums, classes,
|
|
|
|
/// structs, and unions.
|
|
|
|
LookupTagName,
|
|
|
|
/// Member name lookup, which finds the names of
|
|
|
|
/// class/struct/union members.
|
|
|
|
LookupMemberName,
|
2009-02-05 00:44:47 +08:00
|
|
|
// Look up of an operator name (e.g., operator+) for use with
|
|
|
|
// operator overloading. This lookup is similar to ordinary name
|
|
|
|
// lookup, but will ignore any declarations that are class
|
|
|
|
// members.
|
|
|
|
LookupOperatorName,
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
/// Look up of a name that precedes the '::' scope resolution
|
|
|
|
/// operator in C++. This lookup completely ignores operator,
|
|
|
|
/// function, and enumerator names (C++ [basic.lookup.qual]p1).
|
|
|
|
LookupNestedNameSpecifierName,
|
|
|
|
/// Look up a namespace name within a C++ using directive or
|
|
|
|
/// namespace alias definition, ignoring non-namespace names (C++
|
|
|
|
/// [basic.lookup.udir]p1).
|
2009-02-25 04:03:32 +08:00
|
|
|
LookupNamespaceName,
|
2009-04-24 07:18:26 +08:00
|
|
|
/// Look up an ordinary name that is going to be redeclared as a
|
|
|
|
/// name with linkage. This lookup ignores any declarations that
|
|
|
|
/// are outside of the current scope unless they have linkage. See
|
|
|
|
/// C99 6.2.2p4-5 and C++ [basic.link]p6.
|
|
|
|
LookupRedeclarationWithLinkage,
|
|
|
|
/// Look up the name of an Objective-C protocol.
|
2009-04-24 08:11:27 +08:00
|
|
|
LookupObjCProtocolName,
|
|
|
|
/// Look up the name of an Objective-C implementation
|
|
|
|
LookupObjCImplementationName,
|
|
|
|
/// Look up the name of an Objective-C category implementation
|
|
|
|
LookupObjCCategoryImplName
|
2009-01-15 06:20:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// @brief Represents the results of name lookup.
|
|
|
|
///
|
|
|
|
/// An instance of the LookupResult class captures the results of a
|
|
|
|
/// single name lookup, which can return no result (nothing found),
|
|
|
|
/// a single declaration, a set of overloaded functions, or an
|
|
|
|
/// ambiguity. Use the getKind() method to determine which of these
|
|
|
|
/// results occurred for a given lookup.
|
|
|
|
///
|
|
|
|
/// Any non-ambiguous lookup can be converted into a single
|
2009-02-05 01:27:36 +08:00
|
|
|
/// (possibly NULL) @c NamedDecl* via a conversion function or the
|
2009-01-15 06:20:51 +08:00
|
|
|
/// getAsDecl() method. This conversion permits the common-case
|
|
|
|
/// usage in C and Objective-C where name lookup will always return
|
|
|
|
/// a single declaration.
|
2009-01-17 09:13:24 +08:00
|
|
|
struct LookupResult {
|
2009-01-15 06:20:51 +08:00
|
|
|
/// The kind of entity that is actually stored within the
|
|
|
|
/// LookupResult object.
|
2009-01-17 09:13:24 +08:00
|
|
|
enum {
|
2009-02-05 01:27:36 +08:00
|
|
|
/// First is a single declaration (a NamedDecl*), which may be NULL.
|
2009-01-15 06:20:51 +08:00
|
|
|
SingleDecl,
|
2009-01-15 08:26:24 +08:00
|
|
|
|
2009-02-04 03:21:40 +08:00
|
|
|
/// First is a single declaration (an OverloadedFunctionDecl*).
|
|
|
|
OverloadedDeclSingleDecl,
|
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
/// [First, Last) is an iterator range represented as opaque
|
|
|
|
/// pointers used to reconstruct IdentifierResolver::iterators.
|
|
|
|
OverloadedDeclFromIdResolver,
|
2009-01-15 08:26:24 +08:00
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
/// [First, Last) is an iterator range represented as opaque
|
|
|
|
/// pointers used to reconstruct DeclContext::lookup_iterators.
|
|
|
|
OverloadedDeclFromDeclContext,
|
2009-01-15 08:26:24 +08:00
|
|
|
|
|
|
|
/// First is a pointer to a BasePaths structure, which is owned
|
|
|
|
/// by the LookupResult. Last is non-zero to indicate that the
|
|
|
|
/// ambiguity is caused by two names found in base class
|
|
|
|
/// subobjects of different types.
|
2009-02-04 03:21:40 +08:00
|
|
|
AmbiguousLookupStoresBasePaths,
|
|
|
|
|
|
|
|
/// [First, Last) is an iterator range represented as opaque
|
|
|
|
/// pointers used to reconstruct new'ed Decl*[] array containing
|
|
|
|
/// found ambiguous decls. LookupResult is owner of this array.
|
|
|
|
AmbiguousLookupStoresDecls
|
2009-01-15 06:20:51 +08:00
|
|
|
} StoredKind;
|
|
|
|
|
|
|
|
/// The first lookup result, whose contents depend on the kind of
|
2009-02-05 01:27:36 +08:00
|
|
|
/// lookup result. This may be a NamedDecl* (if StoredKind ==
|
|
|
|
/// SingleDecl), OverloadedFunctionDecl* (if StoredKind ==
|
|
|
|
/// OverloadedDeclSingleDecl), the opaque pointer from an
|
2009-01-15 06:20:51 +08:00
|
|
|
/// IdentifierResolver::iterator (if StoredKind ==
|
2009-01-15 08:26:24 +08:00
|
|
|
/// OverloadedDeclFromIdResolver), a DeclContext::lookup_iterator
|
|
|
|
/// (if StoredKind == OverloadedDeclFromDeclContext), or a
|
2009-02-04 03:21:40 +08:00
|
|
|
/// BasePaths pointer (if StoredKind == AmbiguousLookupStoresBasePaths).
|
2009-01-15 06:20:51 +08:00
|
|
|
mutable uintptr_t First;
|
|
|
|
|
|
|
|
/// The last lookup result, whose contents depend on the kind of
|
|
|
|
/// lookup result. This may be unused (if StoredKind ==
|
2009-01-15 08:26:24 +08:00
|
|
|
/// SingleDecl), it may have the same type as First (for
|
|
|
|
/// overloaded function declarations), or is may be used as a
|
2009-02-04 03:21:40 +08:00
|
|
|
/// Boolean value (if StoredKind == AmbiguousLookupStoresBasePaths).
|
2009-01-15 06:20:51 +08:00
|
|
|
mutable uintptr_t Last;
|
|
|
|
|
|
|
|
/// Context - The context in which we will build any
|
|
|
|
/// OverloadedFunctionDecl nodes needed by the conversion to
|
|
|
|
/// Decl*.
|
|
|
|
ASTContext *Context;
|
|
|
|
|
|
|
|
/// @brief The kind of entity found by name lookup.
|
|
|
|
enum LookupKind {
|
|
|
|
/// @brief No entity found met the criteria.
|
|
|
|
NotFound = 0,
|
2009-01-15 08:26:24 +08:00
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
/// @brief Name lookup found a single declaration that met the
|
2009-01-15 08:26:24 +08:00
|
|
|
/// criteria. getAsDecl will return this declaration.
|
2009-01-15 06:20:51 +08:00
|
|
|
Found,
|
2009-01-15 08:26:24 +08:00
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
/// @brief Name lookup found a set of overloaded functions that
|
2009-01-15 08:26:24 +08:00
|
|
|
/// met the criteria. getAsDecl will turn this set of overloaded
|
|
|
|
/// functions into an OverloadedFunctionDecl.
|
2009-01-15 06:20:51 +08:00
|
|
|
FoundOverloaded,
|
2009-01-15 08:26:24 +08:00
|
|
|
|
|
|
|
/// Name lookup results in an ambiguity because multiple
|
|
|
|
/// entities that meet the lookup criteria were found in
|
|
|
|
/// subobjects of different types. For example:
|
|
|
|
/// @code
|
|
|
|
/// struct A { void f(int); }
|
|
|
|
/// struct B { void f(double); }
|
|
|
|
/// struct C : A, B { };
|
|
|
|
/// void test(C c) {
|
|
|
|
/// c.f(0); // error: A::f and B::f come from subobjects of different
|
|
|
|
/// // types. overload resolution is not performed.
|
|
|
|
/// }
|
|
|
|
/// @endcode
|
|
|
|
AmbiguousBaseSubobjectTypes,
|
|
|
|
|
|
|
|
/// Name lookup results in an ambiguity because multiple
|
|
|
|
/// nonstatic entities that meet the lookup criteria were found
|
|
|
|
/// in different subobjects of the same type. For example:
|
|
|
|
/// @code
|
|
|
|
/// struct A { int x; };
|
|
|
|
/// struct B : A { };
|
|
|
|
/// struct C : A { };
|
|
|
|
/// struct D : B, C { };
|
|
|
|
/// int test(D d) {
|
|
|
|
/// return d.x; // error: 'x' is found in two A subobjects (of B and C)
|
|
|
|
/// }
|
|
|
|
/// @endcode
|
2009-02-04 03:21:40 +08:00
|
|
|
AmbiguousBaseSubobjects,
|
|
|
|
|
|
|
|
/// Name lookup results in an ambiguity because multiple definitions
|
|
|
|
/// of entity that meet the lookup criteria were found in different
|
|
|
|
/// declaration contexts.
|
|
|
|
/// @code
|
|
|
|
/// namespace A {
|
|
|
|
/// int i;
|
|
|
|
/// namespace B { int i; }
|
|
|
|
/// int test() {
|
|
|
|
/// using namespace B;
|
|
|
|
/// return i; // error 'i' is found in namespace A and A::B
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// @endcode
|
|
|
|
AmbiguousReference
|
2009-01-15 06:20:51 +08:00
|
|
|
};
|
|
|
|
|
2009-02-05 01:27:36 +08:00
|
|
|
static LookupResult CreateLookupResult(ASTContext &Context, NamedDecl *D);
|
2009-01-15 10:19:31 +08:00
|
|
|
|
2009-01-17 09:13:24 +08:00
|
|
|
static LookupResult CreateLookupResult(ASTContext &Context,
|
|
|
|
IdentifierResolver::iterator F,
|
|
|
|
IdentifierResolver::iterator L);
|
|
|
|
|
|
|
|
static LookupResult CreateLookupResult(ASTContext &Context,
|
|
|
|
DeclContext::lookup_iterator F,
|
|
|
|
DeclContext::lookup_iterator L);
|
|
|
|
|
|
|
|
static LookupResult CreateLookupResult(ASTContext &Context, BasePaths *Paths,
|
|
|
|
bool DifferentSubobjectTypes) {
|
|
|
|
LookupResult Result;
|
2009-02-04 03:21:40 +08:00
|
|
|
Result.StoredKind = AmbiguousLookupStoresBasePaths;
|
2009-01-17 09:13:24 +08:00
|
|
|
Result.First = reinterpret_cast<uintptr_t>(Paths);
|
|
|
|
Result.Last = DifferentSubobjectTypes? 1 : 0;
|
|
|
|
Result.Context = &Context;
|
|
|
|
return Result;
|
|
|
|
}
|
2009-01-15 10:19:31 +08:00
|
|
|
|
2009-02-04 03:21:40 +08:00
|
|
|
template <typename Iterator>
|
|
|
|
static LookupResult CreateLookupResult(ASTContext &Context,
|
|
|
|
Iterator B, std::size_t Len) {
|
2009-02-05 01:27:36 +08:00
|
|
|
NamedDecl ** Array = new NamedDecl*[Len];
|
2009-02-04 03:21:40 +08:00
|
|
|
for (std::size_t Idx = 0; Idx < Len; ++Idx, ++B)
|
|
|
|
Array[Idx] = *B;
|
|
|
|
LookupResult Result;
|
|
|
|
Result.StoredKind = AmbiguousLookupStoresDecls;
|
|
|
|
Result.First = reinterpret_cast<uintptr_t>(Array);
|
|
|
|
Result.Last = reinterpret_cast<uintptr_t>(Array + Len);
|
|
|
|
Result.Context = &Context;
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
LookupKind getKind() const;
|
|
|
|
|
|
|
|
/// @brief Determine whether name look found something.
|
|
|
|
operator bool() const { return getKind() != NotFound; }
|
|
|
|
|
2009-01-15 08:26:24 +08:00
|
|
|
/// @brief Determines whether the lookup resulted in an ambiguity.
|
2009-02-04 03:21:40 +08:00
|
|
|
bool isAmbiguous() const {
|
|
|
|
return StoredKind == AmbiguousLookupStoresBasePaths ||
|
|
|
|
StoredKind == AmbiguousLookupStoresDecls;
|
|
|
|
}
|
2009-01-15 08:26:24 +08:00
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
/// @brief Allows conversion of a lookup result into a
|
|
|
|
/// declaration, with the same behavior as getAsDecl.
|
2009-02-05 01:27:36 +08:00
|
|
|
operator NamedDecl*() const { return getAsDecl(); }
|
2009-01-15 06:20:51 +08:00
|
|
|
|
2009-02-05 01:27:36 +08:00
|
|
|
NamedDecl* getAsDecl() const;
|
2009-01-15 08:26:24 +08:00
|
|
|
|
|
|
|
BasePaths *getBasePaths() const;
|
2009-02-03 05:35:47 +08:00
|
|
|
|
|
|
|
/// \brief Iterate over the results of name lookup.
|
|
|
|
///
|
|
|
|
/// The @c iterator class provides iteration over the results of a
|
|
|
|
/// non-ambiguous name lookup.
|
|
|
|
class iterator {
|
|
|
|
/// The LookupResult structure we're iterating through.
|
|
|
|
LookupResult *Result;
|
|
|
|
|
|
|
|
/// The current position of this iterator within the sequence of
|
|
|
|
/// results. This value will have the same representation as the
|
|
|
|
/// @c First field in the LookupResult structure.
|
|
|
|
mutable uintptr_t Current;
|
|
|
|
|
|
|
|
public:
|
2009-02-05 01:27:36 +08:00
|
|
|
typedef NamedDecl * value_type;
|
|
|
|
typedef NamedDecl * reference;
|
|
|
|
typedef NamedDecl * pointer;
|
2009-02-03 05:35:47 +08:00
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
typedef std::forward_iterator_tag iterator_category;
|
|
|
|
|
|
|
|
iterator() : Result(0), Current(0) { }
|
|
|
|
|
|
|
|
iterator(LookupResult *Res, uintptr_t Cur) : Result(Res), Current(Cur) { }
|
|
|
|
|
|
|
|
reference operator*() const;
|
|
|
|
|
|
|
|
pointer operator->() const { return **this; }
|
|
|
|
|
|
|
|
iterator &operator++();
|
|
|
|
|
|
|
|
iterator operator++(int) {
|
|
|
|
iterator tmp(*this);
|
|
|
|
++(*this);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend inline bool operator==(iterator const& x, iterator const& y) {
|
|
|
|
return x.Current == y.Current;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend inline bool operator!=(iterator const& x, iterator const& y) {
|
|
|
|
return x.Current != y.Current;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
friend class iterator;
|
|
|
|
|
|
|
|
iterator begin();
|
|
|
|
iterator end();
|
2009-04-02 05:51:26 +08:00
|
|
|
|
|
|
|
/// \brief Free the memory associated with this lookup.
|
|
|
|
void Destroy();
|
2009-01-15 06:20:51 +08:00
|
|
|
};
|
|
|
|
|
2009-02-04 03:21:40 +08:00
|
|
|
private:
|
|
|
|
typedef llvm::SmallVector<LookupResult, 3> LookupResultsVecTy;
|
|
|
|
|
|
|
|
std::pair<bool, LookupResult> CppLookupName(Scope *S, DeclarationName Name,
|
|
|
|
LookupNameKind NameKind,
|
|
|
|
bool RedeclarationOnly);
|
2009-04-08 02:28:06 +08:00
|
|
|
ObjCMethodDecl *FindMethodInNestedImplementations(
|
|
|
|
const ObjCInterfaceDecl *IFace,
|
|
|
|
const Selector &Sel);
|
2009-02-04 03:21:40 +08:00
|
|
|
|
|
|
|
public:
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
/// Determines whether D is a suitable lookup result according to the
|
|
|
|
/// lookup criteria.
|
2009-02-25 04:03:32 +08:00
|
|
|
static bool isAcceptableLookupResult(NamedDecl *D, LookupNameKind NameKind,
|
2009-02-06 03:25:20 +08:00
|
|
|
unsigned IDNS) {
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
switch (NameKind) {
|
|
|
|
case Sema::LookupOrdinaryName:
|
|
|
|
case Sema::LookupTagName:
|
|
|
|
case Sema::LookupMemberName:
|
2009-02-25 04:03:32 +08:00
|
|
|
case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping
|
2009-04-24 08:11:27 +08:00
|
|
|
case Sema::LookupObjCProtocolName:
|
|
|
|
case Sema::LookupObjCImplementationName:
|
|
|
|
case Sema::LookupObjCCategoryImplName:
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
return D->isInIdentifierNamespace(IDNS);
|
|
|
|
|
2009-02-05 00:44:47 +08:00
|
|
|
case Sema::LookupOperatorName:
|
|
|
|
return D->isInIdentifierNamespace(IDNS) &&
|
|
|
|
!D->getDeclContext()->isRecord();
|
|
|
|
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
case Sema::LookupNestedNameSpecifierName:
|
|
|
|
return isa<TypedefDecl>(D) || D->isInIdentifierNamespace(Decl::IDNS_Tag);
|
|
|
|
|
|
|
|
case Sema::LookupNamespaceName:
|
2009-03-29 07:53:49 +08:00
|
|
|
return isa<NamespaceDecl>(D) || isa<NamespaceAliasDecl>(D);
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(false &&
|
2009-02-06 03:25:20 +08:00
|
|
|
"isAcceptableLookupResult always returns before this point");
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-15 06:20:51 +08:00
|
|
|
LookupResult LookupName(Scope *S, DeclarationName Name,
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
LookupNameKind NameKind,
|
Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:
1) When we're supporting the "implicit function declaration" feature
of C99, these functions will be implicitly declared with the right
signature rather than as a function returning "int" with no
prototype. See PR3541 for the reason why this is important (hint:
GCC always predeclares these functions).
2) If users attempt to redeclare one of these library functions with
an incompatible signature, we produce a hard error.
This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:
'strcpy' was implicitly declared here with type 'char *(char *, char
const *)'
but we should really print out a fake code line showing the
declaration, like this:
'strcpy' was implicitly declared here as:
char *strcpy(char *, char const *)
This would also be good for printing built-in candidates with C++
operator overloading.
The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.
llvm-svn: 64504
2009-02-14 07:20:09 +08:00
|
|
|
bool RedeclarationOnly = false,
|
|
|
|
bool AllowBuiltinCreation = true,
|
|
|
|
SourceLocation Loc = SourceLocation());
|
2009-01-15 06:20:51 +08:00
|
|
|
LookupResult LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
|
Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.
Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.
Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.
All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.
llvm-svn: 63354
2009-01-30 09:04:22 +08:00
|
|
|
LookupNameKind NameKind,
|
|
|
|
bool RedeclarationOnly = false);
|
|
|
|
LookupResult LookupParsedName(Scope *S, const CXXScopeSpec *SS,
|
|
|
|
DeclarationName Name,
|
|
|
|
LookupNameKind NameKind,
|
Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:
1) When we're supporting the "implicit function declaration" feature
of C99, these functions will be implicitly declared with the right
signature rather than as a function returning "int" with no
prototype. See PR3541 for the reason why this is important (hint:
GCC always predeclares these functions).
2) If users attempt to redeclare one of these library functions with
an incompatible signature, we produce a hard error.
This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:
'strcpy' was implicitly declared here with type 'char *(char *, char
const *)'
but we should really print out a fake code line showing the
declaration, like this:
'strcpy' was implicitly declared here as:
char *strcpy(char *, char const *)
This would also be good for printing built-in candidates with C++
operator overloading.
The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.
llvm-svn: 64504
2009-02-14 07:20:09 +08:00
|
|
|
bool RedeclarationOnly = false,
|
|
|
|
bool AllowBuiltinCreation = true,
|
|
|
|
SourceLocation Loc = SourceLocation());
|
2009-03-13 08:33:25 +08:00
|
|
|
|
2009-04-24 07:18:26 +08:00
|
|
|
ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II);
|
2009-04-24 08:11:27 +08:00
|
|
|
ObjCImplementationDecl *LookupObjCImplementation(IdentifierInfo *II);
|
|
|
|
ObjCCategoryImplDecl *LookupObjCCategoryImpl(IdentifierInfo *II);
|
2009-04-24 07:18:26 +08:00
|
|
|
|
2009-03-13 08:33:25 +08:00
|
|
|
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
|
|
|
|
QualType T1, QualType T2,
|
|
|
|
FunctionSet &Functions);
|
|
|
|
|
|
|
|
void ArgumentDependentLookup(DeclarationName Name,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
FunctionSet &Functions);
|
|
|
|
|
2009-02-04 08:32:51 +08:00
|
|
|
void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
|
|
|
|
AssociatedNamespaceSet &AssociatedNamespaces,
|
|
|
|
AssociatedClassSet &AssociatedClasses);
|
|
|
|
|
2009-01-15 08:26:24 +08:00
|
|
|
bool DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
SourceRange LookupRange = SourceRange());
|
2009-01-15 06:20:51 +08:00
|
|
|
//@}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
|
Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:
1) When we're supporting the "implicit function declaration" feature
of C99, these functions will be implicitly declared with the right
signature rather than as a function returning "int" with no
prototype. See PR3541 for the reason why this is important (hint:
GCC always predeclares these functions).
2) If users attempt to redeclare one of these library functions with
an incompatible signature, we produce a hard error.
This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:
'strcpy' was implicitly declared here with type 'char *(char *, char
const *)'
but we should really print out a fake code line showing the
declaration, like this:
'strcpy' was implicitly declared here as:
char *strcpy(char *, char const *)
This would also be good for printing built-in candidates with C++
operator overloading.
The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.
llvm-svn: 64504
2009-02-14 07:20:09 +08:00
|
|
|
Scope *S, bool ForRedeclaration,
|
|
|
|
SourceLocation Loc);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
|
|
|
|
Scope *S);
|
2009-02-15 02:57:46 +08:00
|
|
|
void AddKnownFunctionAttributes(FunctionDecl *FD);
|
2009-01-15 06:20:51 +08:00
|
|
|
|
|
|
|
// More parsing and symbol table subroutines.
|
|
|
|
|
2007-06-11 08:35:03 +08:00
|
|
|
// Decl attributes - this routine is the top level dispatcher.
|
2008-06-29 08:16:31 +08:00
|
|
|
void ProcessDeclAttributes(Decl *D, const Declarator &PD);
|
2008-06-29 07:58:55 +08:00
|
|
|
void ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList);
|
2008-02-04 10:31:56 +08:00
|
|
|
|
2008-02-11 05:38:56 +08:00
|
|
|
void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
|
|
|
|
bool &IncompleteImpl);
|
2008-12-06 02:18:52 +08:00
|
|
|
void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod,
|
|
|
|
ObjCMethodDecl *IntfMethod);
|
2009-05-15 07:52:54 +08:00
|
|
|
bool QualifiedIdConformsQualifiedId(QualType LHS, QualType RHS);
|
2008-11-11 19:37:55 +08:00
|
|
|
|
|
|
|
NamespaceDecl *GetStdNamespace();
|
2009-01-13 03:55:42 +08:00
|
|
|
|
|
|
|
bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl,
|
2009-02-27 03:11:32 +08:00
|
|
|
ObjCInterfaceDecl *IDecl);
|
2008-02-11 05:38:56 +08:00
|
|
|
|
2009-01-06 15:27:21 +08:00
|
|
|
/// CheckProtocolMethodDefs - This routine checks unimplemented
|
2008-09-05 04:01:15 +08:00
|
|
|
/// methods declared in protocol, and those referenced by it.
|
|
|
|
/// \param IDecl - Used for checking for methods which may have been
|
|
|
|
/// inherited.
|
2008-02-09 06:06:17 +08:00
|
|
|
void CheckProtocolMethodDefs(SourceLocation ImpLoc,
|
|
|
|
ObjCProtocolDecl *PDecl,
|
2007-10-03 04:06:01 +08:00
|
|
|
bool& IncompleteImpl,
|
2007-10-09 05:05:34 +08:00
|
|
|
const llvm::DenseSet<Selector> &InsMap,
|
2008-09-05 04:01:15 +08:00
|
|
|
const llvm::DenseSet<Selector> &ClsMap,
|
|
|
|
ObjCInterfaceDecl *IDecl);
|
2007-09-30 01:14:55 +08:00
|
|
|
|
2007-10-03 05:43:37 +08:00
|
|
|
/// CheckImplementationIvars - This routine checks if the instance variables
|
|
|
|
/// listed in the implelementation match those listed in the interface.
|
2008-01-08 03:49:32 +08:00
|
|
|
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
|
|
|
|
ObjCIvarDecl **Fields, unsigned nIvars,
|
2008-02-11 05:38:56 +08:00
|
|
|
SourceLocation Loc);
|
2007-10-03 05:43:37 +08:00
|
|
|
|
2007-09-30 01:14:55 +08:00
|
|
|
/// ImplMethodsVsClassMethods - This is main routine to warn if any method
|
2009-03-01 08:56:52 +08:00
|
|
|
/// remains unimplemented in the class or category @implementation.
|
|
|
|
void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
|
|
|
|
ObjCContainerDecl* IDecl,
|
|
|
|
bool IncompleteImpl = false);
|
2007-09-30 01:14:55 +08:00
|
|
|
|
2007-10-06 02:00:57 +08:00
|
|
|
/// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
|
|
|
|
/// true, or false, accordingly.
|
2008-01-08 03:49:32 +08:00
|
|
|
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
|
2008-10-21 18:37:50 +08:00
|
|
|
const ObjCMethodDecl *PrevMethod,
|
|
|
|
bool matchBasedOnSizeAndAlignment = false);
|
2007-10-11 05:53:07 +08:00
|
|
|
|
2009-05-02 04:07:12 +08:00
|
|
|
/// MatchAllMethodDeclarations - Check methods declaraed in interface or
|
|
|
|
/// or protocol against those declared in their implementations.
|
|
|
|
void MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
|
|
|
|
const llvm::DenseSet<Selector> &ClsMap,
|
|
|
|
llvm::DenseSet<Selector> &InsMapSeen,
|
|
|
|
llvm::DenseSet<Selector> &ClsMapSeen,
|
|
|
|
ObjCImplDecl* IMPDecl,
|
|
|
|
ObjCContainerDecl* IDecl,
|
|
|
|
bool &IncompleteImpl,
|
|
|
|
bool ImmediateClass);
|
|
|
|
|
2007-10-14 08:58:41 +08:00
|
|
|
/// AddInstanceMethodToGlobalPool - All instance methods in a translation
|
|
|
|
/// unit are added to a global pool. This allows us to efficiently associate
|
|
|
|
/// a selector with a method declaraation for purposes of typechecking
|
|
|
|
/// messages sent to "id" (where the class of the object is unknown).
|
2008-01-08 03:49:32 +08:00
|
|
|
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method);
|
2007-10-14 08:58:41 +08:00
|
|
|
|
2008-09-30 22:38:43 +08:00
|
|
|
/// LookupInstanceMethodInGlobalPool - Returns the method and warns if
|
|
|
|
/// there are multiple signatures.
|
|
|
|
ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R);
|
2009-04-25 05:10:55 +08:00
|
|
|
|
|
|
|
/// LookupFactoryMethodInGlobalPool - Returns the method and warns if
|
|
|
|
/// there are multiple signatures.
|
|
|
|
ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R);
|
2008-09-30 22:38:43 +08:00
|
|
|
|
2007-10-14 08:58:41 +08:00
|
|
|
/// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
|
2008-01-08 03:49:32 +08:00
|
|
|
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method);
|
2006-11-03 14:42:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-11-10 13:29:30 +08:00
|
|
|
// Statement Parsing Callbacks: SemaStmt.cpp.
|
2007-03-15 05:52:03 +08:00
|
|
|
public:
|
2009-05-18 05:11:30 +08:00
|
|
|
virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr);
|
2008-12-21 20:04:03 +08:00
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc);
|
|
|
|
virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
|
|
|
|
MultiStmtArg Elts,
|
|
|
|
bool isStmtExpr);
|
2009-03-30 00:50:03 +08:00
|
|
|
virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
|
2009-03-29 03:18:32 +08:00
|
|
|
SourceLocation StartLoc,
|
2008-12-21 20:04:03 +08:00
|
|
|
SourceLocation EndLoc);
|
2008-12-29 00:13:43 +08:00
|
|
|
virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal,
|
|
|
|
SourceLocation DotDotDotLoc, ExprArg RHSVal,
|
2009-03-04 12:23:07 +08:00
|
|
|
SourceLocation ColonLoc);
|
|
|
|
virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt);
|
|
|
|
|
2008-12-29 00:13:43 +08:00
|
|
|
virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
|
|
|
|
SourceLocation ColonLoc,
|
|
|
|
StmtArg SubStmt, Scope *CurScope);
|
2009-01-11 08:38:46 +08:00
|
|
|
virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
|
|
|
|
IdentifierInfo *II,
|
|
|
|
SourceLocation ColonLoc,
|
|
|
|
StmtArg SubStmt);
|
2009-05-18 02:26:53 +08:00
|
|
|
virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
|
|
|
|
FullExprArg CondVal, StmtArg ThenVal,
|
|
|
|
SourceLocation ElseLoc, StmtArg ElseVal);
|
2009-01-11 08:38:46 +08:00
|
|
|
virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond);
|
|
|
|
virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
|
|
|
|
StmtArg Switch, StmtArg Body);
|
2009-05-18 05:22:26 +08:00
|
|
|
virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
|
|
|
|
FullExprArg Cond, StmtArg Body);
|
2009-01-17 07:28:06 +08:00
|
|
|
virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
|
|
|
|
SourceLocation WhileLoc, ExprArg Cond);
|
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
StmtArg First, ExprArg Second,
|
|
|
|
ExprArg Third, SourceLocation RParenLoc,
|
|
|
|
StmtArg Body);
|
|
|
|
virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
StmtArg First, ExprArg Second,
|
|
|
|
SourceLocation RParenLoc, StmtArg Body);
|
2009-01-18 21:19:59 +08:00
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
|
|
|
|
SourceLocation LabelLoc,
|
|
|
|
IdentifierInfo *LabelII);
|
|
|
|
virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
|
|
|
|
SourceLocation StarLoc,
|
|
|
|
ExprArg DestExp);
|
|
|
|
virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
|
|
|
|
Scope *CurScope);
|
|
|
|
virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
|
|
|
|
Scope *CurScope);
|
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
|
|
|
|
ExprArg RetValExp);
|
|
|
|
OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc,
|
|
|
|
Expr *RetValExp);
|
|
|
|
|
2009-01-19 00:53:17 +08:00
|
|
|
virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
|
|
|
|
bool IsSimple,
|
|
|
|
bool IsVolatile,
|
|
|
|
unsigned NumOutputs,
|
|
|
|
unsigned NumInputs,
|
|
|
|
std::string *Names,
|
|
|
|
MultiExprArg Constraints,
|
|
|
|
MultiExprArg Exprs,
|
|
|
|
ExprArg AsmString,
|
|
|
|
MultiExprArg Clobbers,
|
|
|
|
SourceLocation RParenLoc);
|
2009-01-19 01:43:11 +08:00
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
|
|
|
|
SourceLocation RParen,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy Parm, StmtArg Body,
|
2009-01-19 01:43:11 +08:00
|
|
|
StmtArg CatchList);
|
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
|
|
|
|
StmtArg Body);
|
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
|
|
|
|
StmtArg Try,
|
|
|
|
StmtArg Catch, StmtArg Finally);
|
|
|
|
|
|
|
|
virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
|
2009-02-12 04:05:44 +08:00
|
|
|
ExprArg Throw,
|
|
|
|
Scope *CurScope);
|
2009-01-19 01:43:11 +08:00
|
|
|
virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
|
|
|
|
ExprArg SynchExpr,
|
|
|
|
StmtArg SynchBody);
|
2008-12-22 00:41:36 +08:00
|
|
|
|
2009-05-19 04:51:54 +08:00
|
|
|
VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
SourceLocation Loc,
|
|
|
|
SourceRange Range);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D);
|
2009-05-19 04:51:54 +08:00
|
|
|
|
2008-12-23 03:15:10 +08:00
|
|
|
virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy ExDecl,
|
2008-12-23 03:15:10 +08:00
|
|
|
StmtArg HandlerBlock);
|
2008-12-23 05:35:02 +08:00
|
|
|
virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
|
|
|
|
StmtArg TryBlock,
|
|
|
|
MultiStmtArg Handlers);
|
2009-04-28 05:33:24 +08:00
|
|
|
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
|
2008-12-22 00:41:36 +08:00
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2006-11-10 13:29:30 +08:00
|
|
|
// Expression Parsing Callbacks: SemaExpr.cpp.
|
2006-11-03 14:42:29 +08:00
|
|
|
|
2009-02-19 05:56:37 +08:00
|
|
|
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
|
2009-05-09 04:20:55 +08:00
|
|
|
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
|
|
|
|
ObjCMethodDecl *Getter,
|
|
|
|
SourceLocation Loc);
|
2009-05-14 02:09:35 +08:00
|
|
|
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
|
|
|
Expr **Args, unsigned NumArgs);
|
2009-02-16 06:43:40 +08:00
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
// Primary Expressions.
|
Introduce code modification hints into the diagnostics system. When we
know how to recover from an error, we can attach a hint to the
diagnostic that states how to modify the code, which can be one of:
- Insert some new code (a text string) at a particular source
location
- Remove the code within a given range
- Replace the code within a given range with some new code (a text
string)
Right now, we use these hints to annotate diagnostic information. For
example, if one uses the '>>' in a template argument in C++98, as in
this code:
template<int I> class B { };
B<1000 >> 2> *b1;
we'll warn that the behavior will change in C++0x. The fix is to
insert parenthese, so we use code insertion annotations to illustrate
where the parentheses go:
test.cpp:10:10: warning: use of right-shift operator ('>>') in template
argument will require parentheses in C++0x
B<1000 >> 2> *b1;
^
( )
Use of these annotations is partially implemented for HTML
diagnostics, but it's not (yet) producing valid HTML, which may be
related to PR2386, so it has been #if 0'd out.
In this future, we could consider hooking this mechanism up to the
rewriter to actually try to fix these problems during compilation (or,
after a compilation whose only errors have fixes). For now, however, I
suggest that we use these code modification hints whenever we can, so
that we get better diagnostics now and will have better coverage when
we find better ways to use this information.
This also fixes PR3410 by placing the complaint about missing tokens
just after the previous token (rather than at the location of the next
token).
llvm-svn: 65570
2009-02-27 05:00:50 +08:00
|
|
|
virtual SourceRange getExprRange(ExprTy *E) const;
|
|
|
|
|
2009-01-19 02:53:16 +08:00
|
|
|
virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
|
|
|
|
IdentifierInfo &II,
|
|
|
|
bool HasTrailingLParen,
|
2009-02-04 04:19:35 +08:00
|
|
|
const CXXScopeSpec *SS = 0,
|
|
|
|
bool isAddressOfOperand = false);
|
2009-01-19 02:53:16 +08:00
|
|
|
virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr(Scope *S,
|
2008-11-20 03:09:45 +08:00
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
OverloadedOperatorKind Op,
|
|
|
|
bool HasTrailingLParen,
|
2009-02-04 04:19:35 +08:00
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
bool isAddressOfOperand);
|
2009-01-19 02:53:16 +08:00
|
|
|
virtual OwningExprResult ActOnCXXConversionFunctionExpr(Scope *S,
|
2008-11-20 03:09:45 +08:00
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
TypeTy *Ty,
|
|
|
|
bool HasTrailingLParen,
|
2009-02-04 04:19:35 +08:00
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
bool isAddressOfOperand);
|
2009-01-06 13:10:23 +08:00
|
|
|
DeclRefExpr *BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
|
|
|
|
bool TypeDependent, bool ValueDependent,
|
|
|
|
const CXXScopeSpec *SS = 0);
|
2009-04-15 14:41:24 +08:00
|
|
|
VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
|
|
|
|
llvm::SmallVectorImpl<FieldDecl *> &Path);
|
2009-01-19 02:53:16 +08:00
|
|
|
OwningExprResult
|
2009-01-07 08:43:41 +08:00
|
|
|
BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
|
|
|
|
FieldDecl *Field,
|
|
|
|
Expr *BaseObjectExpr = 0,
|
|
|
|
SourceLocation OpLoc = SourceLocation());
|
2009-01-19 02:53:16 +08:00
|
|
|
OwningExprResult ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
|
|
|
|
DeclarationName Name,
|
|
|
|
bool HasTrailingLParen,
|
|
|
|
const CXXScopeSpec *SS,
|
2009-02-04 04:19:35 +08:00
|
|
|
bool isAddressOfOperand = false);
|
2009-01-19 02:53:16 +08:00
|
|
|
|
|
|
|
virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
|
|
|
|
tok::TokenKind Kind);
|
|
|
|
virtual OwningExprResult ActOnNumericConstant(const Token &);
|
|
|
|
virtual OwningExprResult ActOnCharacterConstant(const Token &);
|
|
|
|
virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
|
|
|
|
ExprArg Val);
|
2006-11-09 14:32:27 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// ActOnStringLiteral - The specified tokens were lexed as pasted string
|
2006-11-09 14:32:27 +08:00
|
|
|
/// fragments (e.g. "foo" "bar" L"baz").
|
2009-01-19 08:08:26 +08:00
|
|
|
virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
|
|
|
|
unsigned NumToks);
|
2009-01-19 02:53:16 +08:00
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
// Binary/Unary Operators. 'Tok' is the token for the operator.
|
2009-03-14 07:49:33 +08:00
|
|
|
OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc,
|
|
|
|
unsigned OpcIn,
|
|
|
|
ExprArg InputArg);
|
2009-01-19 08:08:26 +08:00
|
|
|
virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
|
|
|
|
tok::TokenKind Op, ExprArg Input);
|
2008-11-12 01:56:53 +08:00
|
|
|
|
2009-03-14 05:01:28 +08:00
|
|
|
OwningExprResult CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc,
|
|
|
|
bool isSizeOf, SourceRange R);
|
|
|
|
OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
|
|
|
|
bool isSizeOf, SourceRange R);
|
2009-03-14 07:49:33 +08:00
|
|
|
virtual OwningExprResult
|
|
|
|
ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
|
|
|
|
void *TyOrEx, const SourceRange &ArgRange);
|
2009-03-14 05:01:28 +08:00
|
|
|
|
2009-01-25 04:17:12 +08:00
|
|
|
bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R);
|
2008-11-12 01:56:53 +08:00
|
|
|
bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc,
|
|
|
|
const SourceRange &R, bool isSizeof);
|
2009-01-19 08:08:26 +08:00
|
|
|
|
|
|
|
virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
|
|
|
|
tok::TokenKind Kind,
|
|
|
|
ExprArg Input);
|
|
|
|
|
|
|
|
virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation LLoc,
|
|
|
|
ExprArg Idx,
|
|
|
|
SourceLocation RLoc);
|
|
|
|
virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
|
|
|
SourceLocation MemberLoc,
|
2009-03-05 06:30:12 +08:00
|
|
|
IdentifierInfo &Member,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy ImplDecl);
|
2009-01-19 08:08:26 +08:00
|
|
|
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
2008-12-22 13:46:06 +08:00
|
|
|
FunctionDecl *FDecl,
|
2009-02-27 07:50:07 +08:00
|
|
|
const FunctionProtoType *Proto,
|
2008-12-22 13:46:06 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation RParenLoc);
|
2009-01-19 08:08:26 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
|
2006-11-03 14:42:29 +08:00
|
|
|
/// This provides the location of the left/right parens and a list of comma
|
|
|
|
/// locations.
|
2009-01-19 08:08:26 +08:00
|
|
|
virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2009-01-20 06:31:54 +08:00
|
|
|
virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
|
|
|
|
SourceLocation RParenLoc, ExprArg Op);
|
|
|
|
|
|
|
|
virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
|
|
|
|
TypeTy *Ty,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
ExprArg Op);
|
|
|
|
|
|
|
|
virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
|
|
|
|
MultiExprArg InitList,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2009-01-22 08:58:24 +08:00
|
|
|
virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig,
|
|
|
|
SourceLocation Loc,
|
2009-03-28 08:41:23 +08:00
|
|
|
bool GNUSyntax,
|
2009-01-22 08:58:24 +08:00
|
|
|
OwningExprResult Init);
|
|
|
|
|
2009-01-20 06:31:54 +08:00
|
|
|
virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
|
|
|
|
tok::TokenKind Kind,
|
|
|
|
ExprArg LHS, ExprArg RHS);
|
|
|
|
OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc,
|
|
|
|
unsigned Opc, Expr *lhs, Expr *rhs);
|
2008-11-07 07:29:22 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
|
2006-11-03 14:42:29 +08:00
|
|
|
/// in the case of a the GNU conditional expr extension.
|
2009-01-20 06:31:54 +08:00
|
|
|
virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
|
|
|
|
SourceLocation ColonLoc,
|
|
|
|
ExprArg Cond, ExprArg LHS,
|
|
|
|
ExprArg RHS);
|
2006-12-05 02:06:35 +08:00
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
/// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc,
|
|
|
|
SourceLocation LabLoc,
|
|
|
|
IdentifierInfo *LabelII);
|
|
|
|
|
|
|
|
virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt,
|
|
|
|
SourceLocation RPLoc); // "({..})"
|
2007-08-31 01:45:32 +08:00
|
|
|
|
|
|
|
/// __builtin_offsetof(type, a.b[123][456].c)
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
|
|
|
|
SourceLocation BuiltinLoc,
|
|
|
|
SourceLocation TypeLoc,
|
|
|
|
TypeTy *Arg1,
|
|
|
|
OffsetOfComponent *CompPtr,
|
|
|
|
unsigned NumComponents,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2007-08-02 06:05:33 +08:00
|
|
|
// __builtin_types_compatible_p(type1, type2)
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
|
|
|
|
TypeTy *arg1, TypeTy *arg2,
|
|
|
|
SourceLocation RPLoc);
|
|
|
|
|
2007-08-04 05:21:27 +08:00
|
|
|
// __builtin_choose_expr(constExpr, expr1, expr2)
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
|
|
|
|
ExprArg cond, ExprArg expr1,
|
|
|
|
ExprArg expr2, SourceLocation RPLoc);
|
|
|
|
|
2007-10-16 04:28:48 +08:00
|
|
|
// __builtin_va_arg(expr, type)
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
|
|
|
|
ExprArg expr, TypeTy *type,
|
|
|
|
SourceLocation RPLoc);
|
2008-09-04 02:15:37 +08:00
|
|
|
|
2008-11-29 12:51:27 +08:00
|
|
|
// __null
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
|
2008-11-29 12:51:27 +08:00
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
//===------------------------- "Block" Extension ------------------------===//
|
|
|
|
|
|
|
|
/// ActOnBlockStart - This callback is invoked when a block literal is
|
|
|
|
/// started.
|
2008-10-10 09:28:17 +08:00
|
|
|
virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
|
2009-03-16 01:47:39 +08:00
|
|
|
|
2008-10-10 09:28:17 +08:00
|
|
|
/// ActOnBlockArguments - This callback allows processing of block arguments.
|
|
|
|
/// If there are no arguments, this is still invoked.
|
2009-02-05 06:31:32 +08:00
|
|
|
virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope);
|
2009-03-16 01:47:39 +08:00
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
/// ActOnBlockError - If there is an error parsing a block, this callback
|
|
|
|
/// is invoked to pop the information about the block from the action impl.
|
|
|
|
virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
|
2009-03-16 01:47:39 +08:00
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
/// ActOnBlockStmtExpr - This is called when the body of a block statement
|
|
|
|
/// literal was successfully completed. ^(int x){...}
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc,
|
|
|
|
StmtArg Body, Scope *CurScope);
|
2008-09-04 02:15:37 +08:00
|
|
|
|
2009-02-16 06:43:40 +08:00
|
|
|
//===---------------------------- C++ Features --------------------------===//
|
|
|
|
|
2008-04-27 21:50:30 +08:00
|
|
|
// Act on C++ namespaces
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
|
|
|
|
IdentifierInfo *Ident,
|
|
|
|
SourceLocation LBrace);
|
|
|
|
virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace);
|
|
|
|
|
|
|
|
virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
|
|
|
|
SourceLocation UsingLoc,
|
|
|
|
SourceLocation NamespcLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation IdentLoc,
|
|
|
|
IdentifierInfo *NamespcName,
|
|
|
|
AttributeList *AttrList);
|
2009-03-28 13:27:17 +08:00
|
|
|
|
2009-02-04 03:21:40 +08:00
|
|
|
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
|
2009-03-29 06:53:22 +08:00
|
|
|
SourceLocation NamespaceLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
SourceLocation AliasLoc,
|
|
|
|
IdentifierInfo *Alias,
|
|
|
|
const CXXScopeSpec &SS,
|
2009-03-29 06:53:22 +08:00
|
|
|
SourceLocation IdentLoc,
|
|
|
|
IdentifierInfo *Ident);
|
2009-03-28 13:27:17 +08:00
|
|
|
|
2008-10-07 01:10:33 +08:00
|
|
|
/// AddCXXDirectInitializerToDecl - This action is called immediately after
|
|
|
|
/// ActOnDeclarator, when a C++ direct initializer is present.
|
|
|
|
/// e.g: "int x(1);"
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
|
2008-10-07 01:10:33 +08:00
|
|
|
SourceLocation LParenLoc,
|
2009-03-16 01:47:39 +08:00
|
|
|
MultiExprArg Exprs,
|
2008-10-07 01:10:33 +08:00
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2009-04-24 13:16:06 +08:00
|
|
|
/// InitializeVarWithConstructor - Creates an CXXConstructExpr
|
|
|
|
/// and sets it as the initializer for the the passed in VarDecl.
|
2009-04-17 07:50:50 +08:00
|
|
|
void InitializeVarWithConstructor(VarDecl *VD,
|
|
|
|
CXXConstructorDecl *Constructor,
|
|
|
|
QualType DeclInitType,
|
|
|
|
Expr **Exprs, unsigned NumExprs);
|
2009-05-31 04:36:53 +08:00
|
|
|
|
|
|
|
/// MaybeBindToTemporary - If the passed in expression has a record type with
|
|
|
|
/// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
|
|
|
|
/// it simply returns the passed in expression.
|
|
|
|
OwningExprResult MaybeBindToTemporary(Expr *E);
|
|
|
|
|
2008-11-05 23:29:30 +08:00
|
|
|
/// InitializationKind - Represents which kind of C++ initialization
|
|
|
|
/// [dcl.init] a routine is to perform.
|
|
|
|
enum InitializationKind {
|
|
|
|
IK_Direct, ///< Direct initialization
|
|
|
|
IK_Copy, ///< Copy initialization
|
|
|
|
IK_Default ///< Default initialization
|
|
|
|
};
|
|
|
|
|
2008-11-04 04:45:27 +08:00
|
|
|
CXXConstructorDecl *
|
2008-11-05 23:29:30 +08:00
|
|
|
PerformInitializationByConstructor(QualType ClassType,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation Loc, SourceRange Range,
|
2008-11-24 13:29:24 +08:00
|
|
|
DeclarationName InitEntity,
|
2008-11-05 23:29:30 +08:00
|
|
|
InitializationKind Kind);
|
2008-11-04 04:45:27 +08:00
|
|
|
|
2008-10-28 03:41:14 +08:00
|
|
|
/// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
|
|
|
|
tok::TokenKind Kind,
|
|
|
|
SourceLocation LAngleBracketLoc,
|
|
|
|
TypeTy *Ty,
|
|
|
|
SourceLocation RAngleBracketLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
ExprArg E,
|
|
|
|
SourceLocation RParenLoc);
|
2007-02-13 09:51:42 +08:00
|
|
|
|
2009-03-16 01:47:39 +08:00
|
|
|
/// ActOnCXXTypeid - Parse typeid( something ).
|
|
|
|
virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc,
|
|
|
|
SourceLocation LParenLoc, bool isType,
|
|
|
|
void *TyOrExpr,
|
|
|
|
SourceLocation RParenLoc);
|
2008-11-11 19:37:55 +08:00
|
|
|
|
2008-07-01 18:37:29 +08:00
|
|
|
//// ActOnCXXThis - Parse 'this' pointer.
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc);
|
2008-07-01 18:37:29 +08:00
|
|
|
|
2007-09-16 22:56:35 +08:00
|
|
|
/// ActOnCXXBoolLiteral - Parse {true,false} literals.
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
|
|
|
|
tok::TokenKind Kind);
|
|
|
|
|
2009-05-11 02:38:11 +08:00
|
|
|
/// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
|
|
|
|
virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
|
|
|
|
|
2008-02-26 08:51:44 +08:00
|
|
|
//// ActOnCXXThrow - Parse throw expressions.
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc,
|
|
|
|
ExprArg expr);
|
2009-04-28 04:27:31 +08:00
|
|
|
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E);
|
2008-02-26 08:51:44 +08:00
|
|
|
|
2008-08-22 23:38:55 +08:00
|
|
|
/// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
|
|
|
|
/// Can be interpreted either as function-style casting ("int(x)")
|
|
|
|
/// or class type construction ("ClassType(x,y,z)")
|
|
|
|
/// or creation of a value-initialized type ("int()").
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
|
|
|
|
TypeTy *TypeRep,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
MultiExprArg Exprs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
2008-08-22 23:38:55 +08:00
|
|
|
|
2008-11-22 03:14:01 +08:00
|
|
|
/// ActOnCXXNew - Parsed a C++ 'new' expression.
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
|
|
|
|
SourceLocation PlacementLParen,
|
|
|
|
MultiExprArg PlacementArgs,
|
|
|
|
SourceLocation PlacementRParen,
|
|
|
|
bool ParenTypeId, Declarator &D,
|
|
|
|
SourceLocation ConstructorLParen,
|
|
|
|
MultiExprArg ConstructorArgs,
|
|
|
|
SourceLocation ConstructorRParen);
|
2009-05-21 08:00:09 +08:00
|
|
|
OwningExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
|
|
|
|
SourceLocation PlacementLParen,
|
|
|
|
MultiExprArg PlacementArgs,
|
|
|
|
SourceLocation PlacementRParen,
|
|
|
|
bool ParenTypeId,
|
|
|
|
QualType AllocType,
|
|
|
|
SourceLocation TypeLoc,
|
|
|
|
SourceRange TypeRange,
|
|
|
|
ExprArg ArraySize,
|
|
|
|
SourceLocation ConstructorLParen,
|
|
|
|
MultiExprArg ConstructorArgs,
|
|
|
|
SourceLocation ConstructorRParen);
|
|
|
|
|
|
|
|
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
|
|
|
|
SourceRange R);
|
2009-02-10 02:24:27 +08:00
|
|
|
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
|
|
|
|
bool UseGlobal, QualType AllocType, bool IsArray,
|
2008-12-04 04:26:15 +08:00
|
|
|
Expr **PlaceArgs, unsigned NumPlaceArgs,
|
|
|
|
FunctionDecl *&OperatorNew,
|
|
|
|
FunctionDecl *&OperatorDelete);
|
2009-02-10 02:24:27 +08:00
|
|
|
bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
|
|
|
|
DeclarationName Name, Expr** Args,
|
|
|
|
unsigned NumArgs, DeclContext *Ctx,
|
2008-12-05 06:20:51 +08:00
|
|
|
bool AllowMissing, FunctionDecl *&Operator);
|
2008-12-04 04:26:15 +08:00
|
|
|
void DeclareGlobalNewDelete();
|
|
|
|
void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
|
|
|
|
QualType Argument);
|
2008-11-22 03:14:01 +08:00
|
|
|
|
|
|
|
/// ActOnCXXDelete - Parsed a C++ 'delete' expression
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc,
|
|
|
|
bool UseGlobal, bool ArrayForm,
|
|
|
|
ExprArg Operand);
|
2008-11-22 03:14:01 +08:00
|
|
|
|
2008-09-10 10:17:11 +08:00
|
|
|
/// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
|
|
|
|
/// C++ if/switch/while/for statement.
|
|
|
|
/// e.g: "if (int x = f()) {...}"
|
2009-03-16 01:47:39 +08:00
|
|
|
virtual OwningExprResult ActOnCXXConditionDeclarationExpr(Scope *S,
|
2008-09-10 10:17:11 +08:00
|
|
|
SourceLocation StartLoc,
|
|
|
|
Declarator &D,
|
|
|
|
SourceLocation EqualLoc,
|
2009-03-16 01:47:39 +08:00
|
|
|
ExprArg AssignExprVal);
|
2008-09-10 10:17:11 +08:00
|
|
|
|
2009-01-06 04:52:13 +08:00
|
|
|
/// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
|
|
|
|
/// pseudo-functions.
|
|
|
|
virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
|
|
|
|
SourceLocation KWLoc,
|
|
|
|
SourceLocation LParen,
|
|
|
|
TypeTy *Ty,
|
|
|
|
SourceLocation RParen);
|
|
|
|
|
2009-05-18 02:41:29 +08:00
|
|
|
virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
|
|
|
|
|
2009-03-12 00:48:53 +08:00
|
|
|
bool RequireCompleteDeclContext(const CXXScopeSpec &SS);
|
Introduce a representation for types that we referred to via a
qualified name, e.g.,
foo::x
so that we retain the nested-name-specifier as written in the source
code and can reproduce that qualified name when printing the types
back (e.g., in diagnostics). This is PR3493, which won't be complete
until finished the other tasks mentioned near the end of this commit.
The parser's representation of nested-name-specifiers, CXXScopeSpec,
is now a bit fatter, because it needs to contain the scopes that
precede each '::' and keep track of whether the global scoping
operator '::' was at the beginning. For example, we need to keep track
of the leading '::', 'foo', and 'bar' in
::foo::bar::x
The Action's CXXScopeTy * is no longer a DeclContext *. It's now the
opaque version of the new NestedNameSpecifier, which contains a single
component of a nested-name-specifier (either a DeclContext * or a Type
*, bitmangled).
The new sugar type QualifiedNameType composes a sequence of
NestedNameSpecifiers with a representation of the type we're actually
referring to. At present, we only build QualifiedNameType nodes within
Sema::getTypeName. This will be extended to other type-constructing
actions (e.g., ActOnClassTemplateId).
Also on the way: QualifiedDeclRefExprs will also store a sequence of
NestedNameSpecifiers, so that we can print out the property
nested-name-specifier. I expect to also use this for handling
dependent names like Fibonacci<I - 1>::value.
llvm-svn: 67265
2009-03-19 08:18:19 +08:00
|
|
|
|
|
|
|
DeclContext *computeDeclContext(const CXXScopeSpec &SS);
|
Introduce a new expression type, UnresolvedDeclRefExpr, that describes
dependent qualified-ids such as
Fibonacci<N - 1>::value
where N is a template parameter. These references are "unresolved"
because the name is dependent and, therefore, cannot be resolved to a
declaration node (as we would do for a DeclRefExpr or
QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to
DeclRefExprs, QualifiedDeclRefExprs, etc.
Also, be a bit more careful about keeping only a single set of
specializations for a class template, and instantiating from the
definition of that template rather than a previous declaration. In
general, we need a better solution for this for all TagDecls, because
it's too easy to accidentally look at a declaration that isn't the
definition.
We can now process a simple Fibonacci computation described as a
template metaprogram.
llvm-svn: 67308
2009-03-20 01:26:29 +08:00
|
|
|
bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
|
2009-05-12 03:58:34 +08:00
|
|
|
CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
|
|
|
|
bool isUnknownSpecialization(const CXXScopeSpec &SS);
|
2009-03-12 00:48:53 +08:00
|
|
|
|
2008-11-09 01:17:31 +08:00
|
|
|
/// ActOnCXXGlobalScopeSpecifier - Return the object that represents the
|
|
|
|
/// global scope ('::').
|
|
|
|
virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S,
|
|
|
|
SourceLocation CCLoc);
|
|
|
|
|
|
|
|
/// ActOnCXXNestedNameSpecifier - Called during parsing of a
|
|
|
|
/// nested-name-specifier. e.g. for "foo::bar::" we parsed "foo::" and now
|
|
|
|
/// we want to resolve "bar::". 'SS' is empty or the previously parsed
|
|
|
|
/// nested-name part ("foo::"), 'IdLoc' is the source location of 'bar',
|
|
|
|
/// 'CCLoc' is the location of '::' and 'II' is the identifier for 'bar'.
|
|
|
|
/// Returns a CXXScopeTy* object representing the C++ scope.
|
|
|
|
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation IdLoc,
|
|
|
|
SourceLocation CCLoc,
|
2008-11-18 04:34:05 +08:00
|
|
|
IdentifierInfo &II);
|
2008-11-09 01:17:31 +08:00
|
|
|
|
Implement parsing of nested-name-specifiers that involve template-ids, e.g.,
std::vector<int>::allocator_type
When we parse a template-id that names a type, it will become either a
template-id annotation (which is a parsed representation of a
template-id that has not yet been through semantic analysis) or a
typename annotation (where semantic analysis has resolved the
template-id to an actual type), depending on the context. We only
produce a type in contexts where we know that we only need type
information, e.g., in a type specifier. Otherwise, we create a
template-id annotation that can later be "upgraded" by transforming it
into a typename annotation when the parser needs a type. This occurs,
for example, when we've parsed "std::vector<int>" above and then see
the '::' after it. However, it means that when writing something like
this:
template<> class Outer::Inner<int> { ... };
We have two tokens to represent Outer::Inner<int>: one token for the
nested name specifier Outer::, and one template-id annotation token
for Inner<int>, which will be passed to semantic analysis to define
the class template specialization.
Most of the churn in the template tests in this patch come from an
improvement in our error recovery from ill-formed template-ids.
llvm-svn: 65467
2009-02-26 03:37:18 +08:00
|
|
|
/// ActOnCXXNestedNameSpecifier - Called during parsing of a
|
|
|
|
/// nested-name-specifier that involves a template-id, e.g.,
|
|
|
|
/// "foo::bar<int, float>::", and now we need to build a scope
|
|
|
|
/// specifier. \p SS is empty or the previously parsed nested-name
|
|
|
|
/// part ("foo::"), \p Type is the already-parsed class template
|
|
|
|
/// specialization (or other template-id that names a type), \p
|
|
|
|
/// TypeRange is the source range where the type is located, and \p
|
|
|
|
/// CCLoc is the location of the trailing '::'.
|
|
|
|
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
TypeTy *Type,
|
|
|
|
SourceRange TypeRange,
|
|
|
|
SourceLocation CCLoc);
|
|
|
|
|
2008-11-09 01:17:31 +08:00
|
|
|
/// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
|
|
|
|
/// scope or nested-name-specifier) is parsed, part of a declarator-id.
|
|
|
|
/// After this method is called, according to [C++ 3.4.3p3], names should be
|
|
|
|
/// looked up in the declarator-id's scope, until the declarator is parsed and
|
|
|
|
/// ActOnCXXExitDeclaratorScope is called.
|
|
|
|
/// The 'SS' should be a non-empty valid CXXScopeSpec.
|
|
|
|
virtual void ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
|
|
|
|
|
|
|
|
/// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
|
|
|
|
/// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
|
|
|
|
/// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
|
|
|
|
/// Used to indicate that names should revert to being looked up in the
|
|
|
|
/// defining scope.
|
2008-12-16 08:38:16 +08:00
|
|
|
virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
|
2008-11-09 01:17:31 +08:00
|
|
|
|
2007-08-22 01:43:55 +08:00
|
|
|
// ParseObjCStringLiteral - Parse Objective-C string literals.
|
2007-12-12 09:04:12 +08:00
|
|
|
virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
|
|
|
ExprTy **Strings,
|
|
|
|
unsigned NumStrings);
|
2007-08-22 23:14:15 +08:00
|
|
|
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
|
2007-10-17 06:51:17 +08:00
|
|
|
SourceLocation EncodeLoc,
|
2007-08-22 23:14:15 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
TypeTy *Ty,
|
|
|
|
SourceLocation RParenLoc);
|
2007-10-17 04:40:23 +08:00
|
|
|
|
|
|
|
// ParseObjCSelectorExpression - Build selector expression for @selector
|
|
|
|
virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
|
|
|
|
SourceLocation AtLoc,
|
2007-10-17 07:21:02 +08:00
|
|
|
SourceLocation SelLoc,
|
2007-10-17 04:40:23 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2007-08-22 23:14:15 +08:00
|
|
|
|
2007-10-18 00:58:11 +08:00
|
|
|
// ParseObjCProtocolExpression - Build protocol expression for @protocol
|
|
|
|
virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
|
|
|
|
SourceLocation AtLoc,
|
|
|
|
SourceLocation ProtoLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2008-04-14 05:30:24 +08:00
|
|
|
|
2009-01-06 03:45:36 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Declarations
|
|
|
|
//
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S,
|
|
|
|
SourceLocation ExternLoc,
|
|
|
|
SourceLocation LangLoc,
|
|
|
|
const char *Lang,
|
|
|
|
unsigned StrSize,
|
|
|
|
SourceLocation LBraceLoc);
|
|
|
|
virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S,
|
|
|
|
DeclPtrTy LinkageSpec,
|
|
|
|
SourceLocation RBraceLoc);
|
2009-01-06 03:45:36 +08:00
|
|
|
|
|
|
|
|
2008-04-14 05:30:24 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Classes
|
|
|
|
//
|
2008-11-09 00:45:02 +08:00
|
|
|
virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
|
|
|
|
const CXXScopeSpec *SS);
|
2009-04-13 01:16:29 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
|
|
|
|
Declarator &D,
|
|
|
|
ExprTy *BitfieldWidth,
|
2009-04-13 01:16:29 +08:00
|
|
|
ExprTy *Init,
|
|
|
|
bool Deleted = false);
|
2008-07-01 18:37:29 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
|
2008-11-05 12:29:56 +08:00
|
|
|
Scope *S,
|
|
|
|
IdentifierInfo *MemberOrBase,
|
|
|
|
SourceLocation IdLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
ExprTy **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2008-11-04 01:51:48 +08:00
|
|
|
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
|
2009-03-25 10:58:17 +08:00
|
|
|
SourceLocation ColonLoc,
|
|
|
|
MemInitTy **MemInits, unsigned NumMemInits);
|
|
|
|
|
2008-07-01 18:37:29 +08:00
|
|
|
virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy TagDecl,
|
2008-07-01 18:37:29 +08:00
|
|
|
SourceLocation LBrac,
|
|
|
|
SourceLocation RBrac);
|
|
|
|
|
2009-05-28 07:11:45 +08:00
|
|
|
virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
|
|
|
|
DeclPtrTy Method);
|
|
|
|
virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param);
|
|
|
|
virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
|
|
|
|
DeclPtrTy Method);
|
2008-12-17 05:30:33 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
|
|
|
|
ExprArg AssertExpr,
|
|
|
|
ExprArg AssertMessageExpr);
|
2009-03-14 08:25:26 +08:00
|
|
|
|
2009-05-12 06:55:49 +08:00
|
|
|
virtual bool ActOnFriendDecl(Scope *S, SourceLocation FriendLoc,
|
|
|
|
DeclPtrTy Dcl);
|
|
|
|
|
2009-04-25 16:28:21 +08:00
|
|
|
QualType CheckConstructorDeclarator(Declarator &D, QualType R,
|
|
|
|
FunctionDecl::StorageClass& SC);
|
2009-04-25 16:35:12 +08:00
|
|
|
void CheckConstructor(CXXConstructorDecl *Constructor);
|
2009-04-25 16:28:21 +08:00
|
|
|
QualType CheckDestructorDeclarator(Declarator &D,
|
|
|
|
FunctionDecl::StorageClass& SC);
|
2009-04-25 16:35:12 +08:00
|
|
|
void CheckConversionDeclarator(Declarator &D, QualType &R,
|
2008-11-08 04:08:42 +08:00
|
|
|
FunctionDecl::StorageClass& SC);
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion);
|
2008-10-31 17:07:45 +08:00
|
|
|
|
2008-10-23 08:40:37 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Derived Classes
|
|
|
|
//
|
|
|
|
|
|
|
|
/// ActOnBaseSpecifier - Parsed a base specifier
|
2009-03-03 12:44:36 +08:00
|
|
|
CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
|
|
|
|
SourceRange SpecifierRange,
|
|
|
|
bool Virtual, AccessSpecifier Access,
|
|
|
|
QualType BaseType,
|
|
|
|
SourceLocation BaseLoc);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
|
2008-10-23 08:40:37 +08:00
|
|
|
SourceRange SpecifierRange,
|
|
|
|
bool Virtual, AccessSpecifier Access,
|
2009-03-03 12:44:36 +08:00
|
|
|
TypeTy *basetype, SourceLocation
|
|
|
|
BaseLoc);
|
2008-10-23 08:40:37 +08:00
|
|
|
|
2009-03-03 12:44:36 +08:00
|
|
|
bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
|
|
|
|
unsigned NumBases);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
|
2008-10-23 08:40:37 +08:00
|
|
|
unsigned NumBases);
|
|
|
|
|
|
|
|
bool IsDerivedFrom(QualType Derived, QualType Base);
|
2008-10-24 12:54:22 +08:00
|
|
|
bool IsDerivedFrom(QualType Derived, QualType Base, BasePaths &Paths);
|
2009-01-15 08:26:24 +08:00
|
|
|
bool LookupInBases(CXXRecordDecl *Class, const MemberLookupCriteria& Criteria,
|
|
|
|
BasePaths &Paths);
|
2008-10-25 00:17:19 +08:00
|
|
|
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
|
|
|
|
SourceLocation Loc, SourceRange Range);
|
2009-05-14 05:11:42 +08:00
|
|
|
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
|
|
|
|
unsigned InaccessibleBaseID,
|
|
|
|
unsigned AmbigiousBaseConvID,
|
|
|
|
SourceLocation Loc, SourceRange Range,
|
|
|
|
DeclarationName Name);
|
|
|
|
|
2009-01-16 08:38:09 +08:00
|
|
|
std::string getAmbiguousPathsDisplayString(BasePaths &Paths);
|
2009-05-14 09:09:04 +08:00
|
|
|
|
|
|
|
/// CheckReturnTypeCovariance - Checks whether two types are covariant,
|
|
|
|
/// according to C++ [class.virtual]p5.
|
|
|
|
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
|
|
|
|
const CXXMethodDecl *Old);
|
|
|
|
|
2008-04-14 05:30:24 +08:00
|
|
|
|
2009-03-27 13:05:05 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Access Control
|
|
|
|
//
|
|
|
|
|
|
|
|
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
|
|
|
|
NamedDecl *PrevMemberDecl,
|
|
|
|
AccessSpecifier LexicalAS);
|
|
|
|
|
|
|
|
bool CheckBaseClassAccess(QualType Derived, QualType Base,
|
2009-05-14 05:11:42 +08:00
|
|
|
unsigned InaccessibleBaseID,
|
|
|
|
BasePaths& Paths, SourceLocation AccessLoc,
|
|
|
|
DeclarationName Name);
|
2009-03-27 13:05:05 +08:00
|
|
|
|
|
|
|
|
2009-03-24 09:19:16 +08:00
|
|
|
enum AbstractDiagSelID {
|
|
|
|
AbstractNone = -1,
|
|
|
|
AbstractReturnType,
|
|
|
|
AbstractParamType,
|
|
|
|
AbstractVariableType,
|
|
|
|
AbstractFieldType
|
|
|
|
};
|
|
|
|
|
|
|
|
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
|
2009-03-25 01:23:42 +08:00
|
|
|
AbstractDiagSelID SelID = AbstractNone,
|
|
|
|
const CXXRecordDecl *CurrentRD = 0);
|
2009-03-23 04:18:17 +08:00
|
|
|
|
2008-11-07 06:13:31 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Overloaded Operators [C++ 13.5]
|
|
|
|
//
|
|
|
|
|
|
|
|
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
|
|
|
|
|
2008-12-06 02:15:24 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Templates [C++ 14]
|
|
|
|
//
|
2009-03-31 08:43:58 +08:00
|
|
|
virtual TemplateNameKind isTemplateName(const IdentifierInfo &II, Scope *S,
|
2009-03-31 06:58:21 +08:00
|
|
|
TemplateTy &Template,
|
2009-02-10 02:46:07 +08:00
|
|
|
const CXXScopeSpec *SS = 0);
|
2008-12-06 02:15:24 +08:00
|
|
|
bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
|
2009-03-29 03:18:32 +08:00
|
|
|
TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl);
|
|
|
|
|
|
|
|
virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename,
|
|
|
|
SourceLocation KeyLoc,
|
|
|
|
IdentifierInfo *ParamName,
|
|
|
|
SourceLocation ParamNameLoc,
|
|
|
|
unsigned Depth, unsigned Position);
|
|
|
|
virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam,
|
2009-02-11 03:49:53 +08:00
|
|
|
SourceLocation EqualLoc,
|
|
|
|
SourceLocation DefaultLoc,
|
|
|
|
TypeTy *Default);
|
|
|
|
|
2009-03-03 12:44:36 +08:00
|
|
|
QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
|
|
|
|
unsigned Depth,
|
|
|
|
unsigned Position);
|
|
|
|
virtual void ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParam,
|
2009-02-11 03:49:53 +08:00
|
|
|
SourceLocation EqualLoc,
|
|
|
|
ExprArg Default);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S,
|
|
|
|
SourceLocation TmpLoc,
|
|
|
|
TemplateParamsTy *Params,
|
|
|
|
IdentifierInfo *ParamName,
|
|
|
|
SourceLocation ParamNameLoc,
|
|
|
|
unsigned Depth,
|
|
|
|
unsigned Position);
|
|
|
|
virtual void ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParam,
|
2009-02-11 03:49:53 +08:00
|
|
|
SourceLocation EqualLoc,
|
|
|
|
ExprArg Default);
|
|
|
|
|
2008-12-24 10:52:09 +08:00
|
|
|
virtual TemplateParamsTy *
|
|
|
|
ActOnTemplateParameterList(unsigned Depth,
|
|
|
|
SourceLocation ExportLoc,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy *Params, unsigned NumParams,
|
2008-12-24 10:52:09 +08:00
|
|
|
SourceLocation RAngleLoc);
|
2009-02-11 03:49:53 +08:00
|
|
|
bool CheckTemplateParameterList(TemplateParameterList *NewParams,
|
|
|
|
TemplateParameterList *OldParams);
|
|
|
|
|
2009-03-25 08:13:59 +08:00
|
|
|
virtual DeclResult
|
2009-02-07 06:42:48 +08:00
|
|
|
ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
|
|
|
|
SourceLocation KWLoc, const CXXScopeSpec &SS,
|
|
|
|
IdentifierInfo *Name, SourceLocation NameLoc,
|
|
|
|
AttributeList *Attr,
|
2009-03-26 08:52:18 +08:00
|
|
|
MultiTemplateParamsArg TemplateParameterLists,
|
|
|
|
AccessSpecifier AS);
|
2009-02-07 06:42:48 +08:00
|
|
|
|
2009-03-31 06:58:21 +08:00
|
|
|
QualType CheckTemplateIdType(TemplateName Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceLocation RAngleLoc);
|
2009-03-10 07:48:35 +08:00
|
|
|
|
2009-02-18 07:15:12 +08:00
|
|
|
virtual TypeResult
|
2009-03-31 06:58:21 +08:00
|
|
|
ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
|
|
|
ASTTemplateArgsPtr TemplateArgs,
|
|
|
|
SourceLocation *TemplateArgLocs,
|
|
|
|
SourceLocation RAngleLoc);
|
2009-02-18 07:15:12 +08:00
|
|
|
|
2009-03-31 08:43:58 +08:00
|
|
|
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
|
|
|
|
const IdentifierInfo &Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
const CXXScopeSpec &SS);
|
|
|
|
|
2009-02-26 06:02:03 +08:00
|
|
|
bool CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate,
|
|
|
|
ClassTemplateSpecializationDecl *PrevDecl,
|
|
|
|
SourceLocation TemplateNameLoc,
|
2009-05-14 02:28:20 +08:00
|
|
|
SourceRange ScopeSpecifierRange,
|
|
|
|
bool ExplicitInstantiation);
|
2009-02-26 06:02:03 +08:00
|
|
|
|
2009-03-25 08:13:59 +08:00
|
|
|
virtual DeclResult
|
2009-02-18 07:15:12 +08:00
|
|
|
ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
|
|
|
|
SourceLocation KWLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
2009-03-31 06:58:21 +08:00
|
|
|
TemplateTy Template,
|
2009-02-18 07:15:12 +08:00
|
|
|
SourceLocation TemplateNameLoc,
|
2009-02-10 02:46:07 +08:00
|
|
|
SourceLocation LAngleLoc,
|
2009-02-10 03:34:22 +08:00
|
|
|
ASTTemplateArgsPtr TemplateArgs,
|
2009-02-10 07:23:08 +08:00
|
|
|
SourceLocation *TemplateArgLocs,
|
2009-02-10 02:46:07 +08:00
|
|
|
SourceLocation RAngleLoc,
|
2009-02-18 07:15:12 +08:00
|
|
|
AttributeList *Attr,
|
|
|
|
MultiTemplateParamsArg TemplateParameterLists);
|
2009-02-10 02:46:07 +08:00
|
|
|
|
2009-05-13 08:25:59 +08:00
|
|
|
virtual DeclResult
|
|
|
|
ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
|
|
|
|
unsigned TagSpec,
|
|
|
|
SourceLocation KWLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
TemplateTy Template,
|
|
|
|
SourceLocation TemplateNameLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
|
|
|
ASTTemplateArgsPtr TemplateArgs,
|
|
|
|
SourceLocation *TemplateArgLocs,
|
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
AttributeList *Attr);
|
|
|
|
|
2009-05-14 08:28:11 +08:00
|
|
|
virtual DeclResult
|
|
|
|
ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
|
|
|
|
unsigned TagSpec,
|
|
|
|
SourceLocation KWLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
AttributeList *Attr);
|
|
|
|
|
2009-02-10 07:23:08 +08:00
|
|
|
bool CheckTemplateArgumentList(TemplateDecl *Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-03-10 07:48:35 +08:00
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,
template<> class vector<bool> { };
or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.
llvm-svn: 64716
2009-02-17 09:05:43 +08:00
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
llvm::SmallVectorImpl<TemplateArgument> &Converted);
|
2009-02-10 07:23:08 +08:00
|
|
|
|
|
|
|
bool CheckTemplateArgument(TemplateTypeParmDecl *Param, QualType Arg,
|
|
|
|
SourceLocation ArgLoc);
|
Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,
template<> class vector<bool> { };
or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.
llvm-svn: 64716
2009-02-17 09:05:43 +08:00
|
|
|
bool CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
|
|
|
|
NamedDecl *&Entity);
|
|
|
|
bool CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member);
|
2009-03-03 12:44:36 +08:00
|
|
|
bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
|
|
|
|
QualType InstantiatedParamType, Expr *&Arg,
|
Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,
template<> class vector<bool> { };
or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.
llvm-svn: 64716
2009-02-17 09:05:43 +08:00
|
|
|
llvm::SmallVectorImpl<TemplateArgument> *Converted = 0);
|
2009-02-10 07:23:08 +08:00
|
|
|
bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, DeclRefExpr *Arg);
|
2009-02-07 06:42:48 +08:00
|
|
|
bool TemplateParameterListsAreEqual(TemplateParameterList *New,
|
|
|
|
TemplateParameterList *Old,
|
|
|
|
bool Complain,
|
2009-02-10 08:24:35 +08:00
|
|
|
bool IsTemplateTemplateParm = false,
|
|
|
|
SourceLocation TemplateArgLoc
|
|
|
|
= SourceLocation());
|
2009-02-07 06:42:48 +08:00
|
|
|
|
|
|
|
bool CheckTemplateDeclScope(Scope *S,
|
|
|
|
MultiTemplateParamsArg &TemplateParameterLists);
|
2009-02-05 03:02:06 +08:00
|
|
|
|
2009-03-28 07:10:48 +08:00
|
|
|
/// \brief Called when the parser has parsed a C++ typename
|
|
|
|
/// specifier, e.g., "typename T::type".
|
|
|
|
///
|
|
|
|
/// \param TypenameLoc the location of the 'typename' keyword
|
|
|
|
/// \param SS the nested-name-specifier following the typename (e.g., 'T::').
|
|
|
|
/// \param II the identifier we're retrieving (e.g., 'type' in the example).
|
|
|
|
/// \param IdLoc the location of the identifier.
|
|
|
|
virtual TypeResult
|
|
|
|
ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
|
|
|
|
const IdentifierInfo &II, SourceLocation IdLoc);
|
2009-04-01 08:28:59 +08:00
|
|
|
|
|
|
|
/// \brief Called when the parser has parsed a C++ typename
|
|
|
|
/// specifier that ends in a template-id, e.g.,
|
|
|
|
/// "typename MetaFun::template apply<T1, T2>".
|
|
|
|
///
|
|
|
|
/// \param TypenameLoc the location of the 'typename' keyword
|
|
|
|
/// \param SS the nested-name-specifier following the typename (e.g., 'T::').
|
|
|
|
/// \param TemplateLoc the location of the 'template' keyword, if any.
|
|
|
|
/// \param Ty the type that the typename specifier refers to.
|
|
|
|
virtual TypeResult
|
|
|
|
ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
|
|
|
|
SourceLocation TemplateLoc, TypeTy *Ty);
|
|
|
|
|
2009-03-28 07:10:48 +08:00
|
|
|
QualType CheckTypenameType(NestedNameSpecifier *NNS,
|
|
|
|
const IdentifierInfo &II,
|
|
|
|
SourceRange Range);
|
|
|
|
|
2009-02-28 03:31:52 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Template Instantiation
|
|
|
|
//
|
2009-03-10 08:06:19 +08:00
|
|
|
|
2009-05-15 07:26:13 +08:00
|
|
|
const TemplateArgumentList &getTemplateInstantiationArgs(NamedDecl *D);
|
|
|
|
|
2009-03-10 08:06:19 +08:00
|
|
|
/// \brief A template instantiation that is currently in progress.
|
|
|
|
struct ActiveTemplateInstantiation {
|
2009-03-11 04:44:00 +08:00
|
|
|
/// \brief The kind of template instantiation we are performing
|
|
|
|
enum {
|
|
|
|
/// We are instantiating a template declaration. The entity is
|
2009-05-15 08:01:03 +08:00
|
|
|
/// the declaration we're instantiating (e.g., a CXXRecordDecl).
|
2009-03-11 04:44:00 +08:00
|
|
|
TemplateInstantiation,
|
|
|
|
|
|
|
|
/// We are instantiating a default argument for a template
|
|
|
|
/// parameter. The Entity is the template, and
|
|
|
|
/// TemplateArgs/NumTemplateArguments provides the template
|
|
|
|
/// arguments as specified.
|
|
|
|
DefaultTemplateArgumentInstantiation
|
|
|
|
} Kind;
|
|
|
|
|
2009-03-10 08:06:19 +08:00
|
|
|
/// \brief The point of instantiation within the source code.
|
|
|
|
SourceLocation PointOfInstantiation;
|
|
|
|
|
|
|
|
/// \brief The entity that is being instantiated.
|
2009-03-11 04:44:00 +08:00
|
|
|
uintptr_t Entity;
|
|
|
|
|
|
|
|
// \brief If this the instantiation of a default template
|
2009-05-12 07:53:27 +08:00
|
|
|
// argument, the list of template arguments.
|
2009-03-11 04:44:00 +08:00
|
|
|
const TemplateArgument *TemplateArgs;
|
|
|
|
|
|
|
|
/// \brief The number of template arguments in TemplateArgs.
|
|
|
|
unsigned NumTemplateArgs;
|
2009-03-10 08:06:19 +08:00
|
|
|
|
|
|
|
/// \brief The source range that covers the construct that cause
|
|
|
|
/// the instantiation, e.g., the template-id that causes a class
|
|
|
|
/// template instantiation.
|
|
|
|
SourceRange InstantiationRange;
|
2009-03-11 04:44:00 +08:00
|
|
|
|
|
|
|
friend bool operator==(const ActiveTemplateInstantiation &X,
|
|
|
|
const ActiveTemplateInstantiation &Y) {
|
|
|
|
if (X.Kind != Y.Kind)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (X.Entity != Y.Entity)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (X.Kind) {
|
|
|
|
case TemplateInstantiation:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case DefaultTemplateArgumentInstantiation:
|
|
|
|
return X.TemplateArgs == Y.TemplateArgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend bool operator!=(const ActiveTemplateInstantiation &X,
|
|
|
|
const ActiveTemplateInstantiation &Y) {
|
|
|
|
return !(X == Y);
|
|
|
|
}
|
2009-03-10 08:06:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief List of active template instantiations.
|
|
|
|
///
|
|
|
|
/// This vector is treated as a stack. As one template instantiation
|
|
|
|
/// requires another template instantiation, additional
|
|
|
|
/// instantiations are pushed onto the stack up to a
|
|
|
|
/// user-configurable limit LangOptions::InstantiationDepth.
|
|
|
|
llvm::SmallVector<ActiveTemplateInstantiation, 16>
|
|
|
|
ActiveTemplateInstantiations;
|
|
|
|
|
2009-03-11 02:52:44 +08:00
|
|
|
/// \brief The last template from which a template instantiation
|
|
|
|
/// error or warning was produced.
|
|
|
|
///
|
|
|
|
/// This value is used to suppress printing of redundant template
|
|
|
|
/// instantiation backtraces when there are multiple errors in the
|
|
|
|
/// same instantiation. FIXME: Does this belong in Sema? It's tough
|
|
|
|
/// to implement it anywhere else.
|
2009-03-11 04:44:00 +08:00
|
|
|
ActiveTemplateInstantiation LastTemplateInstantiationErrorContext;
|
2009-03-11 02:52:44 +08:00
|
|
|
|
2009-03-10 08:06:19 +08:00
|
|
|
/// \brief A stack object to be created when performing template
|
|
|
|
/// instantiation.
|
|
|
|
///
|
|
|
|
/// Construction of an object of type \c InstantiatingTemplate
|
|
|
|
/// pushes the current instantiation onto the stack of active
|
|
|
|
/// instantiations. If the size of this stack exceeds the maximum
|
|
|
|
/// number of recursive template instantiations, construction
|
|
|
|
/// produces an error and evaluates true.
|
|
|
|
///
|
|
|
|
/// Destruction of this object will pop the named instantiation off
|
|
|
|
/// the stack.
|
|
|
|
struct InstantiatingTemplate {
|
2009-05-19 01:01:57 +08:00
|
|
|
/// \brief Note that we are instantiating a class template,
|
|
|
|
/// function template, or a member thereof.
|
2009-03-10 08:06:19 +08:00
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
2009-05-19 01:01:57 +08:00
|
|
|
Decl *Entity,
|
2009-03-10 08:06:19 +08:00
|
|
|
SourceRange InstantiationRange = SourceRange());
|
2009-03-11 04:44:00 +08:00
|
|
|
|
|
|
|
/// \brief Note that we are instantiating a default argument in a
|
|
|
|
/// template-id.
|
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
TemplateDecl *Template,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceRange InstantiationRange = SourceRange());
|
|
|
|
|
2009-05-19 01:01:57 +08:00
|
|
|
/// \brief Note that we have finished instantiating this template.
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
~InstantiatingTemplate() { Clear(); }
|
2009-03-10 08:06:19 +08:00
|
|
|
|
|
|
|
/// \brief Determines whether we have exceeded the maximum
|
|
|
|
/// recursive template instantiations.
|
|
|
|
operator bool() const { return Invalid; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Sema &SemaRef;
|
|
|
|
bool Invalid;
|
|
|
|
|
2009-03-11 04:44:00 +08:00
|
|
|
bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
|
|
|
|
SourceRange InstantiationRange);
|
|
|
|
|
2009-03-10 08:06:19 +08:00
|
|
|
InstantiatingTemplate(const InstantiatingTemplate&); // not implemented
|
|
|
|
|
|
|
|
InstantiatingTemplate&
|
|
|
|
operator=(const InstantiatingTemplate&); // not implemented
|
|
|
|
};
|
|
|
|
|
2009-03-11 02:03:33 +08:00
|
|
|
void PrintInstantiationStack();
|
|
|
|
|
2009-05-15 05:44:34 +08:00
|
|
|
/// \brief A stack-allocated class that identifies which local
|
|
|
|
/// variable declaration instantiations are present in this scope.
|
|
|
|
///
|
|
|
|
/// A new instance of this class type will be created whenever we
|
|
|
|
/// instantiate a new function declaration, which will have its own
|
|
|
|
/// set of parameter declarations.
|
|
|
|
class LocalInstantiationScope {
|
|
|
|
/// \brief Reference to the semantic analysis that is performing
|
|
|
|
/// this template instantiation.
|
|
|
|
Sema &SemaRef;
|
|
|
|
|
2009-05-27 13:35:12 +08:00
|
|
|
/// \brief A mapping from local declarations that occur
|
2009-05-15 05:44:34 +08:00
|
|
|
/// within a template to their instantiations.
|
|
|
|
///
|
|
|
|
/// This mapping is used during instantiation to keep track of,
|
|
|
|
/// e.g., function parameter and variable declarations. For example,
|
|
|
|
/// given:
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// template<typename T> T add(T x, T y) { return x + y; }
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// when we instantiate add<int>, we will introduce a mapping from
|
|
|
|
/// the ParmVarDecl for 'x' that occurs in the template to the
|
|
|
|
/// instantiated ParmVarDecl for 'x'.
|
2009-05-27 13:35:12 +08:00
|
|
|
llvm::DenseMap<const Decl *, Decl *> LocalDecls;
|
2009-05-15 05:44:34 +08:00
|
|
|
|
|
|
|
/// \brief The outer scope, in which contains local variable
|
|
|
|
/// definitions from some other instantiation (that is not
|
|
|
|
/// relevant to this particular scope).
|
|
|
|
LocalInstantiationScope *Outer;
|
|
|
|
|
|
|
|
// This class is non-copyable
|
|
|
|
LocalInstantiationScope(const LocalInstantiationScope &);
|
|
|
|
LocalInstantiationScope &operator=(const LocalInstantiationScope &);
|
|
|
|
|
|
|
|
public:
|
|
|
|
LocalInstantiationScope(Sema &SemaRef)
|
|
|
|
: SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) {
|
|
|
|
SemaRef.CurrentInstantiationScope = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
~LocalInstantiationScope() {
|
|
|
|
SemaRef.CurrentInstantiationScope = Outer;
|
|
|
|
}
|
|
|
|
|
2009-05-27 13:35:12 +08:00
|
|
|
Decl *getInstantiationOf(const Decl *D) {
|
|
|
|
Decl *Result = LocalDecls[D];
|
|
|
|
assert(Result && "declaration was not instantiated in this scope!");
|
2009-05-15 05:44:34 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-05-27 13:35:12 +08:00
|
|
|
VarDecl *getInstantiationOf(const VarDecl *Var) {
|
|
|
|
return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var)));
|
|
|
|
}
|
|
|
|
|
2009-05-15 07:26:13 +08:00
|
|
|
ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) {
|
2009-05-27 13:35:12 +08:00
|
|
|
return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var)));
|
2009-05-15 05:44:34 +08:00
|
|
|
}
|
|
|
|
|
2009-05-27 13:35:12 +08:00
|
|
|
void InstantiatedLocal(const Decl *D, Decl *Inst) {
|
|
|
|
Decl *&Stored = LocalDecls[D];
|
|
|
|
assert(!Stored && "Already instantiated this local");
|
|
|
|
Stored = Inst;
|
2009-05-15 05:44:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief The current instantiation scope used to store local
|
|
|
|
/// variables.
|
|
|
|
LocalInstantiationScope *CurrentInstantiationScope;
|
|
|
|
|
2009-05-12 07:53:27 +08:00
|
|
|
QualType InstantiateType(QualType T, const TemplateArgumentList &TemplateArgs,
|
2009-02-28 03:31:52 +08:00
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
2009-03-13 00:53:44 +08:00
|
|
|
|
|
|
|
OwningExprResult InstantiateExpr(Expr *E,
|
2009-05-12 07:53:27 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs);
|
2009-03-13 00:53:44 +08:00
|
|
|
|
2009-05-15 07:26:13 +08:00
|
|
|
OwningStmtResult InstantiateStmt(Stmt *S,
|
|
|
|
const TemplateArgumentList &TemplateArgs);
|
2009-05-21 06:57:03 +08:00
|
|
|
OwningStmtResult InstantiateCompoundStmt(CompoundStmt *S,
|
|
|
|
const TemplateArgumentList &TemplateArgs,
|
|
|
|
bool isStmtExpr);
|
2009-05-15 07:26:13 +08:00
|
|
|
|
2009-03-18 05:15:40 +08:00
|
|
|
Decl *InstantiateDecl(Decl *D, DeclContext *Owner,
|
2009-05-12 07:53:27 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs);
|
2009-03-18 05:15:40 +08:00
|
|
|
|
2009-03-03 12:44:36 +08:00
|
|
|
bool
|
2009-03-26 05:17:03 +08:00
|
|
|
InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
|
|
|
|
CXXRecordDecl *Pattern,
|
2009-05-12 07:53:27 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs);
|
2009-03-26 05:17:03 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
InstantiateClass(SourceLocation PointOfInstantiation,
|
|
|
|
CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
|
2009-05-13 08:25:59 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs,
|
|
|
|
bool ExplicitInstantiation);
|
2009-03-26 05:17:03 +08:00
|
|
|
|
2009-03-03 12:44:36 +08:00
|
|
|
bool
|
|
|
|
InstantiateClassTemplateSpecialization(
|
|
|
|
ClassTemplateSpecializationDecl *ClassTemplateSpec,
|
|
|
|
bool ExplicitInstantiation);
|
2009-02-28 03:31:52 +08:00
|
|
|
|
2009-05-14 04:28:22 +08:00
|
|
|
void InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
|
|
|
CXXRecordDecl *Instantiation,
|
|
|
|
const TemplateArgumentList &TemplateArgs);
|
|
|
|
|
|
|
|
void InstantiateClassTemplateSpecializationMembers(
|
|
|
|
SourceLocation PointOfInstantiation,
|
|
|
|
ClassTemplateSpecializationDecl *ClassTemplateSpec);
|
|
|
|
|
2009-03-27 07:50:42 +08:00
|
|
|
NestedNameSpecifier *
|
|
|
|
InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
|
|
|
|
SourceRange Range,
|
2009-05-12 07:53:27 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs);
|
Introduce a new expression type, UnresolvedDeclRefExpr, that describes
dependent qualified-ids such as
Fibonacci<N - 1>::value
where N is a template parameter. These references are "unresolved"
because the name is dependent and, therefore, cannot be resolved to a
declaration node (as we would do for a DeclRefExpr or
QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to
DeclRefExprs, QualifiedDeclRefExprs, etc.
Also, be a bit more careful about keeping only a single set of
specializations for a class template, and instantiating from the
definition of that template rather than a previous declaration. In
general, we need a better solution for this for all TagDecls, because
it's too easy to accidentally look at a declaration that isn't the
definition.
We can now process a simple Fibonacci computation described as a
template metaprogram.
llvm-svn: 67308
2009-03-20 01:26:29 +08:00
|
|
|
|
2009-04-01 02:38:02 +08:00
|
|
|
TemplateName
|
|
|
|
InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
|
2009-05-12 07:53:27 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs);
|
2009-04-01 02:38:02 +08:00
|
|
|
|
2009-05-19 01:01:57 +08:00
|
|
|
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
|
|
|
|
FunctionDecl *Function);
|
2009-05-14 04:28:22 +08:00
|
|
|
void InstantiateVariableDefinition(VarDecl *Var);
|
|
|
|
|
2009-05-28 01:54:46 +08:00
|
|
|
NamedDecl *InstantiateCurrentDeclRef(NamedDecl *D);
|
2009-05-27 13:35:12 +08:00
|
|
|
|
2009-03-16 02:34:13 +08:00
|
|
|
// Simple function for cloning expressions.
|
|
|
|
template<typename T>
|
|
|
|
OwningExprResult Clone(T *E) {
|
|
|
|
assert(!E->isValueDependent() && !E->isTypeDependent() &&
|
|
|
|
"expression is value or type dependent!");
|
|
|
|
return Owned(E->Clone(Context));
|
|
|
|
}
|
|
|
|
|
2007-09-07 05:24:23 +08:00
|
|
|
// Objective-C declarations.
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
|
|
|
|
IdentifierInfo *ClassName,
|
|
|
|
SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *SuperName,
|
|
|
|
SourceLocation SuperLoc,
|
|
|
|
const DeclPtrTy *ProtoRefs,
|
|
|
|
unsigned NumProtoRefs,
|
|
|
|
SourceLocation EndProtoLoc,
|
|
|
|
AttributeList *AttrList);
|
2007-10-12 07:42:27 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnCompatiblityAlias(
|
2007-10-12 07:42:27 +08:00
|
|
|
SourceLocation AtCompatibilityAliasLoc,
|
|
|
|
IdentifierInfo *AliasName, SourceLocation AliasLocation,
|
|
|
|
IdentifierInfo *ClassName, SourceLocation ClassLocation);
|
2009-03-05 23:22:01 +08:00
|
|
|
|
|
|
|
void CheckForwardProtocolDeclarationForCircularDependency(
|
|
|
|
IdentifierInfo *PName,
|
|
|
|
SourceLocation &PLoc, SourceLocation PrevLoc,
|
|
|
|
const ObjCList<ObjCProtocolDecl> &PList);
|
2007-09-07 05:24:23 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartProtocolInterface(
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation AtProtoInterfaceLoc,
|
2007-09-18 05:07:36 +08:00
|
|
|
IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs,
|
2008-09-26 12:48:09 +08:00
|
|
|
SourceLocation EndProtoLoc,
|
|
|
|
AttributeList *AttrList);
|
2007-09-18 05:07:36 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
|
|
|
|
IdentifierInfo *ClassName,
|
|
|
|
SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *CategoryName,
|
|
|
|
SourceLocation CategoryLoc,
|
|
|
|
const DeclPtrTy *ProtoRefs,
|
|
|
|
unsigned NumProtoRefs,
|
|
|
|
SourceLocation EndProtoLoc);
|
2007-09-19 04:26:58 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartClassImplementation(
|
2008-02-21 06:57:40 +08:00
|
|
|
SourceLocation AtClassImplLoc,
|
2007-09-26 02:38:09 +08:00
|
|
|
IdentifierInfo *ClassName, SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *SuperClassname,
|
|
|
|
SourceLocation SuperClassLoc);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartCategoryImplementation(
|
2007-10-03 00:38:50 +08:00
|
|
|
SourceLocation AtCatImplLoc,
|
|
|
|
IdentifierInfo *ClassName,
|
|
|
|
SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *CatName,
|
|
|
|
SourceLocation CatLoc);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
|
2007-10-03 06:39:18 +08:00
|
|
|
IdentifierInfo **IdentList,
|
|
|
|
unsigned NumElts);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
|
2008-07-22 06:17:28 +08:00
|
|
|
const IdentifierLocPair *IdentList,
|
2008-12-17 09:07:27 +08:00
|
|
|
unsigned NumElts,
|
|
|
|
AttributeList *attrList);
|
2007-10-06 05:01:53 +08:00
|
|
|
|
2008-07-26 12:03:38 +08:00
|
|
|
virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
|
2008-07-22 06:17:28 +08:00
|
|
|
const IdentifierLocPair *ProtocolId,
|
2007-10-11 08:55:41 +08:00
|
|
|
unsigned NumProtocols,
|
2009-03-29 03:18:32 +08:00
|
|
|
llvm::SmallVectorImpl<DeclPtrTy> &Protocols);
|
2008-05-01 08:03:38 +08:00
|
|
|
|
2008-09-24 05:53:23 +08:00
|
|
|
/// Ensure attributes are consistent with type.
|
|
|
|
/// \param [in, out] Attributes The attributes to check; they will
|
|
|
|
/// be modified to be consistent with \arg PropertyTy.
|
|
|
|
void CheckObjCPropertyAttributes(QualType PropertyTy,
|
|
|
|
SourceLocation Loc,
|
|
|
|
unsigned &Attributes);
|
2009-01-09 01:28:14 +08:00
|
|
|
void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
|
2008-05-01 08:03:38 +08:00
|
|
|
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
|
|
|
|
ObjCPropertyDecl *SuperProperty,
|
2008-11-24 11:54:41 +08:00
|
|
|
const IdentifierInfo *Name);
|
2008-05-01 08:03:38 +08:00
|
|
|
void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
|
2008-04-25 03:58:34 +08:00
|
|
|
|
2008-12-07 07:03:39 +08:00
|
|
|
void MergeProtocolPropertiesIntoClass(Decl *CDecl,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy MergeProtocols);
|
2008-05-03 03:17:30 +08:00
|
|
|
|
2009-03-03 03:05:07 +08:00
|
|
|
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
|
|
|
|
ObjCInterfaceDecl *ID);
|
|
|
|
|
2008-12-07 07:03:39 +08:00
|
|
|
void MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
|
2008-05-03 03:17:30 +08:00
|
|
|
ObjCProtocolDecl *PDecl);
|
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
|
|
|
|
DeclPtrTy *allMethods = 0, unsigned allNum = 0,
|
|
|
|
DeclPtrTy *allProperties = 0, unsigned pNum = 0,
|
2009-03-30 00:50:03 +08:00
|
|
|
DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0);
|
2007-09-27 02:27:25 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
|
|
|
|
FieldDeclarator &FD, ObjCDeclSpec &ODS,
|
|
|
|
Selector GetterSel, Selector SetterSel,
|
|
|
|
DeclPtrTy ClassCategory,
|
|
|
|
bool *OverridingProperty,
|
|
|
|
tok::ObjCKeywordKind MethodImplKind);
|
2008-05-06 02:51:55 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc,
|
|
|
|
SourceLocation PropertyLoc,
|
|
|
|
bool ImplKind,DeclPtrTy ClassImplDecl,
|
|
|
|
IdentifierInfo *PropertyId,
|
|
|
|
IdentifierInfo *PropertyIvar);
|
2008-04-18 08:19:30 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnMethodDeclaration(
|
2007-10-27 04:53:56 +08:00
|
|
|
SourceLocation BeginLoc, // location of the + or -.
|
|
|
|
SourceLocation EndLoc, // location of the ; or {.
|
2007-11-10 03:52:12 +08:00
|
|
|
tok::TokenKind MethodType,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
|
2007-11-01 07:53:01 +08:00
|
|
|
Selector Sel,
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
// optional arguments. The number of types/arguments is obtained
|
|
|
|
// from the Sel.getNumArgs().
|
2009-04-12 02:57:04 +08:00
|
|
|
ObjCArgInfo *ArgInfo,
|
2009-01-09 08:38:19 +08:00
|
|
|
llvm::SmallVectorImpl<Declarator> &Cdecls,
|
2007-11-15 20:35:21 +08:00
|
|
|
AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
|
|
|
|
bool isVariadic = false);
|
2007-10-17 07:12:48 +08:00
|
|
|
|
2009-02-26 23:55:06 +08:00
|
|
|
// Helper method for ActOnClassMethod/ActOnInstanceMethod.
|
|
|
|
// Will search "local" class/category implementations for a method decl.
|
2009-03-05 02:15:57 +08:00
|
|
|
// Will also search in class's root looking for instance method.
|
2009-02-26 23:55:06 +08:00
|
|
|
// Returns 0 if no method is found.
|
2009-03-09 02:56:13 +08:00
|
|
|
ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
|
|
|
|
ObjCInterfaceDecl *CDecl);
|
|
|
|
ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
|
|
|
|
ObjCInterfaceDecl *ClassDecl);
|
2009-02-26 23:55:06 +08:00
|
|
|
|
2009-03-10 05:12:44 +08:00
|
|
|
virtual OwningExprResult ActOnClassPropertyRefExpr(
|
|
|
|
IdentifierInfo &receiverName,
|
|
|
|
IdentifierInfo &propertyName,
|
|
|
|
SourceLocation &receiverNameLoc,
|
|
|
|
SourceLocation &propertyNameLoc);
|
|
|
|
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
// ActOnClassMessage - used for both unary and keyword messages.
|
|
|
|
// ArgExprs is optional - if it is present, the number of expressions
|
2007-11-15 21:05:42 +08:00
|
|
|
// is obtained from NumArgs.
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
virtual ExprResult ActOnClassMessage(
|
2007-11-13 04:13:27 +08:00
|
|
|
Scope *S,
|
2009-02-15 02:21:46 +08:00
|
|
|
IdentifierInfo *receivingClassName, Selector Sel, SourceLocation lbrac,
|
|
|
|
SourceLocation receiverLoc, SourceLocation selectorLoc,SourceLocation rbrac,
|
2007-11-15 21:05:42 +08:00
|
|
|
ExprTy **ArgExprs, unsigned NumArgs);
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
|
|
|
|
// ActOnInstanceMessage - used for both unary and keyword messages.
|
|
|
|
// ArgExprs is optional - if it is present, the number of expressions
|
2007-11-15 21:05:42 +08:00
|
|
|
// is obtained from NumArgs.
|
Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.
#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.
#3: It results in many API simplifications. Here are some highlights:
- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).
I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.
Thanks to Chris for talking this through with me and suggesting this approach.
llvm-svn: 42395
2007-09-27 22:38:14 +08:00
|
|
|
virtual ExprResult ActOnInstanceMessage(
|
2007-09-29 06:22:11 +08:00
|
|
|
ExprTy *receiver, Selector Sel,
|
2009-02-15 02:21:46 +08:00
|
|
|
SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac,
|
2007-11-15 21:05:42 +08:00
|
|
|
ExprTy **ArgExprs, unsigned NumArgs);
|
2008-10-14 13:35:18 +08:00
|
|
|
|
|
|
|
/// ActOnPragmaPack - Called on well formed #pragma pack(...).
|
|
|
|
virtual void ActOnPragmaPack(PragmaPackKind Kind,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
ExprTy *Alignment,
|
|
|
|
SourceLocation PragmaLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2009-02-17 09:09:29 +08:00
|
|
|
|
2009-03-24 06:28:25 +08:00
|
|
|
/// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
|
|
|
|
virtual void ActOnPragmaUnused(ExprTy **Exprs, unsigned NumExprs,
|
|
|
|
SourceLocation PragmaLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2009-02-17 09:09:29 +08:00
|
|
|
/// getPragmaPackAlignment() - Return the current alignment as specified by
|
|
|
|
/// the current #pragma pack directive, or 0 if none is currently active.
|
|
|
|
unsigned getPragmaPackAlignment() const;
|
|
|
|
|
|
|
|
/// FreePackedContext - Deallocate and null out PackContext.
|
|
|
|
void FreePackedContext();
|
2008-10-14 13:35:18 +08:00
|
|
|
|
2008-01-17 03:17:22 +08:00
|
|
|
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
|
|
|
|
/// cast. If there is already an implicit cast, merge into the existing one.
|
Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin
bool operator==(int const*, int const*)
can be used for the expression "x1 == x2" given:
struct X {
operator int const*();
} x1, x2;
The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it.
There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.
Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.
As part of this change, ImplicitCastExpr can now be an lvalue.
llvm-svn: 59148
2008-11-13 01:17:38 +08:00
|
|
|
/// If isLvalue, the result of the cast is an lvalue.
|
|
|
|
void ImpCastExprToType(Expr *&Expr, QualType Type, bool isLvalue = false);
|
2008-01-17 03:17:22 +08:00
|
|
|
|
2007-06-05 06:22:31 +08:00
|
|
|
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
|
2007-12-28 13:29:59 +08:00
|
|
|
// functions and arrays to their respective pointers (C99 6.3.2.1).
|
|
|
|
Expr *UsualUnaryConversions(Expr *&expr);
|
2008-05-27 11:33:27 +08:00
|
|
|
|
2007-07-17 05:54:35 +08:00
|
|
|
// DefaultFunctionArrayConversion - converts functions and arrays
|
|
|
|
// to their respective pointers (C99 6.3.2.1).
|
|
|
|
void DefaultFunctionArrayConversion(Expr *&expr);
|
2007-07-14 07:32:42 +08:00
|
|
|
|
2007-08-29 07:30:39 +08:00
|
|
|
// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
|
|
|
|
// do not have a prototype. Integer promotions are performed on each
|
|
|
|
// argument, and arguments that have type float are promoted to double.
|
2007-12-28 13:29:59 +08:00
|
|
|
void DefaultArgumentPromotion(Expr *&Expr);
|
2009-01-17 00:48:51 +08:00
|
|
|
|
|
|
|
// Used for emitting the right warning by DefaultVariadicArgumentPromotion
|
|
|
|
enum VariadicCallType {
|
|
|
|
VariadicFunction,
|
|
|
|
VariadicBlock,
|
|
|
|
VariadicMethod
|
|
|
|
};
|
|
|
|
|
|
|
|
// DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
|
|
|
|
// will warn if the resulting type is not a POD type.
|
2009-04-12 16:11:20 +08:00
|
|
|
bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT);
|
2007-08-29 07:30:39 +08:00
|
|
|
|
2007-06-05 06:22:31 +08:00
|
|
|
// UsualArithmeticConversions - performs the UsualUnaryConversions on it's
|
|
|
|
// operands and then handles various conversions that are common to binary
|
|
|
|
// operators (C99 6.3.1.8). If both operands aren't arithmetic, this
|
|
|
|
// routine returns the first non-arithmetic type found. The client is
|
|
|
|
// responsible for emitting appropriate error diagnostics.
|
2007-08-25 03:07:16 +08:00
|
|
|
QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
|
|
|
|
bool isCompAssign = false);
|
2008-01-05 02:22:42 +08:00
|
|
|
|
Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin
bool operator==(int const*, int const*)
can be used for the expression "x1 == x2" given:
struct X {
operator int const*();
} x1, x2;
The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it.
There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.
Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.
As part of this change, ImplicitCastExpr can now be an lvalue.
llvm-svn: 59148
2008-11-13 01:17:38 +08:00
|
|
|
/// UsualArithmeticConversionsType - handles the various conversions
|
|
|
|
/// that are common to binary operators (C99 6.3.1.8, C++ [expr]p9)
|
|
|
|
/// and returns the result type of that conversion.
|
|
|
|
QualType UsualArithmeticConversionsType(QualType lhs, QualType rhs);
|
|
|
|
|
|
|
|
|
2008-01-05 02:22:42 +08:00
|
|
|
/// AssignConvertType - All of the 'assignment' semantic checks return this
|
|
|
|
/// enum to indicate whether the assignment was allowed. These checks are
|
|
|
|
/// done for simple assignments, as well as initialization, return from
|
|
|
|
/// function, argument passing, etc. The query is phrased in terms of a
|
|
|
|
/// source and destination type.
|
2008-01-05 02:04:52 +08:00
|
|
|
enum AssignConvertType {
|
2008-01-05 02:22:42 +08:00
|
|
|
/// Compatible - the types are compatible according to the standard.
|
2007-05-04 05:03:48 +08:00
|
|
|
Compatible,
|
2008-01-05 02:22:42 +08:00
|
|
|
|
|
|
|
/// PointerToInt - The assignment converts a pointer to an int, which we
|
|
|
|
/// accept as an extension.
|
|
|
|
PointerToInt,
|
|
|
|
|
|
|
|
/// IntToPointer - The assignment converts an int to a pointer, which we
|
|
|
|
/// accept as an extension.
|
|
|
|
IntToPointer,
|
|
|
|
|
|
|
|
/// FunctionVoidPointer - The assignment is between a function pointer and
|
|
|
|
/// void*, which the standard doesn't allow, but we accept as an extension.
|
2008-01-04 06:56:36 +08:00
|
|
|
FunctionVoidPointer,
|
2008-01-05 02:22:42 +08:00
|
|
|
|
|
|
|
/// IncompatiblePointer - The assignment is between two pointers types that
|
|
|
|
/// are not compatible, but we accept them as an extension.
|
2007-05-11 12:00:31 +08:00
|
|
|
IncompatiblePointer,
|
2009-03-23 07:59:44 +08:00
|
|
|
|
|
|
|
/// IncompatiblePointer - The assignment is between two pointers types which
|
|
|
|
/// point to integers which have a different sign, but are otherwise identical.
|
|
|
|
/// This is a subset of the above, but broken out because it's by far the most
|
|
|
|
/// common case of incompatible pointers.
|
|
|
|
IncompatiblePointerSign,
|
|
|
|
|
2008-01-05 02:22:42 +08:00
|
|
|
/// CompatiblePointerDiscardsQualifiers - The assignment discards
|
|
|
|
/// c/v/r qualifiers, which we accept as an extension.
|
|
|
|
CompatiblePointerDiscardsQualifiers,
|
2008-09-04 23:10:53 +08:00
|
|
|
|
2009-01-31 07:17:46 +08:00
|
|
|
/// IncompatibleVectors - The assignment is between two vector types that
|
|
|
|
/// have the same size, which we accept as an extension.
|
|
|
|
IncompatibleVectors,
|
|
|
|
|
2008-09-04 23:31:07 +08:00
|
|
|
/// IntToBlockPointer - The assignment converts an int to a block
|
2008-09-04 23:10:53 +08:00
|
|
|
/// pointer. We disallow this.
|
|
|
|
IntToBlockPointer,
|
|
|
|
|
2008-09-04 23:31:07 +08:00
|
|
|
/// IncompatibleBlockPointer - The assignment is between two block
|
2008-09-04 23:10:53 +08:00
|
|
|
/// pointers types that are not compatible.
|
|
|
|
IncompatibleBlockPointer,
|
|
|
|
|
2008-10-15 06:18:38 +08:00
|
|
|
/// IncompatibleObjCQualifiedId - The assignment is between a qualified
|
|
|
|
/// id type and something else (that is incompatible with it). For example,
|
|
|
|
/// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
|
|
|
|
IncompatibleObjCQualifiedId,
|
|
|
|
|
2008-01-05 02:22:42 +08:00
|
|
|
/// Incompatible - We reject this conversion outright, it is invalid to
|
|
|
|
/// represent it in the AST.
|
|
|
|
Incompatible
|
2007-05-04 05:03:48 +08:00
|
|
|
};
|
2008-01-05 02:04:52 +08:00
|
|
|
|
|
|
|
/// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
|
|
|
|
/// assignment conversion type specified by ConvTy. This returns true if the
|
|
|
|
/// conversion was invalid or false if the conversion was accepted.
|
|
|
|
bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
|
|
|
SourceLocation Loc,
|
|
|
|
QualType DstType, QualType SrcType,
|
|
|
|
Expr *SrcExpr, const char *Flavor);
|
|
|
|
|
|
|
|
/// CheckAssignmentConstraints - Perform type checking for assignment,
|
|
|
|
/// argument passing, variable initialization, and function return values.
|
|
|
|
/// This routine is only used by the following two methods. C99 6.5.16.
|
|
|
|
AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
|
2007-07-14 07:32:42 +08:00
|
|
|
|
2009-04-30 06:16:16 +08:00
|
|
|
// CheckSingleAssignmentConstraints - Currently used by
|
2007-09-16 22:56:35 +08:00
|
|
|
// CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
|
2007-07-14 07:32:42 +08:00
|
|
|
// this routine performs the default function/array converions.
|
2008-01-05 02:04:52 +08:00
|
|
|
AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
|
|
|
|
Expr *&rExpr);
|
2009-04-30 06:16:16 +08:00
|
|
|
|
|
|
|
// \brief If the lhs type is a transparent union, check whether we
|
|
|
|
// can initialize the transparent union with the given expression.
|
|
|
|
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
|
|
|
|
Expr *&rExpr);
|
2007-07-14 07:32:42 +08:00
|
|
|
|
2007-06-07 02:38:38 +08:00
|
|
|
// Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
|
2008-01-05 02:04:52 +08:00
|
|
|
AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
|
|
|
|
QualType rhsType);
|
2008-09-04 23:10:53 +08:00
|
|
|
|
|
|
|
// Helper function for CheckAssignmentConstraints involving two
|
2009-04-20 03:26:31 +08:00
|
|
|
// block pointer types.
|
2008-09-04 23:10:53 +08:00
|
|
|
AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
|
|
|
|
QualType rhsType);
|
2008-09-12 08:47:35 +08:00
|
|
|
|
|
|
|
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
|
2008-10-24 12:54:22 +08:00
|
|
|
|
2008-12-20 01:40:08 +08:00
|
|
|
bool PerformImplicitConversion(Expr *&From, QualType ToType,
|
2009-04-13 01:16:29 +08:00
|
|
|
const char *Flavor,
|
|
|
|
bool AllowExplicit = false,
|
|
|
|
bool Elidable = false);
|
2009-01-14 23:45:31 +08:00
|
|
|
bool PerformImplicitConversion(Expr *&From, QualType ToType,
|
|
|
|
const ImplicitConversionSequence& ICS,
|
2008-12-20 01:40:08 +08:00
|
|
|
const char *Flavor);
|
2008-10-24 12:54:22 +08:00
|
|
|
bool PerformImplicitConversion(Expr *&From, QualType ToType,
|
2008-12-20 01:40:08 +08:00
|
|
|
const StandardConversionSequence& SCS,
|
|
|
|
const char *Flavor);
|
2009-02-07 08:15:38 +08:00
|
|
|
|
2007-05-09 05:09:37 +08:00
|
|
|
/// the following "Check" methods will return a valid/converted QualType
|
|
|
|
/// or a null QualType (indicating an error diagnostic was issued).
|
2009-02-07 08:15:38 +08:00
|
|
|
|
|
|
|
/// type checking binary operators (subroutines of CreateBuiltinBinOp).
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
|
2009-02-08 04:10:22 +08:00
|
|
|
QualType CheckPointerToMemberOperands( // C++ 5.5
|
2009-02-07 08:15:38 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckMultiplyDivideOperands( // C99 6.5.5
|
2009-02-07 08:15:38 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckRemainderOperands( // C99 6.5.5
|
2009-02-07 08:15:38 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckAdditionOperands( // C99 6.5.6
|
2009-03-28 09:22:36 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckSubtractionOperands( // C99 6.5.6
|
2009-03-28 09:22:36 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckShiftOperands( // C99 6.5.7
|
2007-08-25 03:07:16 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckCompareOperands( // C99 6.5.8/9
|
2009-04-07 02:45:53 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc, bool isRelational);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckBitwiseOperands( // C99 6.5.[10...12]
|
2009-02-07 08:15:38 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckLogicalOperands( // C99 6.5.[13,14]
|
2007-07-14 00:58:59 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc);
|
2007-05-07 08:24:15 +08:00
|
|
|
// CheckAssignmentOperands is used for both simple and compound assignment.
|
|
|
|
// For simple assignment, pass both expressions and a null converted type.
|
|
|
|
// For compound assignment, pass both expressions and the converted type.
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
|
2007-08-25 06:33:52 +08:00
|
|
|
Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckCommaOperands( // C99 6.5.17
|
2008-11-18 09:30:42 +08:00
|
|
|
Expr *lex, Expr *&rex, SourceLocation OpLoc);
|
2009-03-13 06:46:12 +08:00
|
|
|
QualType CheckConditionalOperands( // C99 6.5.15
|
2007-07-14 00:58:59 +08:00
|
|
|
Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
|
2009-04-17 01:51:27 +08:00
|
|
|
QualType CXXCheckConditionalOperands( // C++ 5.16
|
|
|
|
Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
|
2009-04-20 03:26:31 +08:00
|
|
|
QualType FindCompositePointerType(Expr *&E1, Expr *&E2); // C++ 5.9
|
2008-07-15 02:02:46 +08:00
|
|
|
|
|
|
|
/// type checking for vector binary operators.
|
|
|
|
inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
|
|
|
|
inline QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx,
|
|
|
|
SourceLocation l, bool isRel);
|
2007-03-31 07:47:58 +08:00
|
|
|
|
2007-09-16 11:34:24 +08:00
|
|
|
/// type checking unary operators (subroutines of ActOnUnaryOp).
|
2007-05-28 07:58:33 +08:00
|
|
|
/// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
|
2008-12-20 17:35:34 +08:00
|
|
|
QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
|
|
|
|
bool isInc);
|
2007-05-19 06:53:50 +08:00
|
|
|
QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
|
|
|
|
QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
|
2009-02-17 16:12:06 +08:00
|
|
|
QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal);
|
2007-07-28 06:15:19 +08:00
|
|
|
|
|
|
|
/// type checking primary expressions.
|
2008-04-19 07:10:10 +08:00
|
|
|
QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
|
2007-07-28 06:15:19 +08:00
|
|
|
IdentifierInfo &Comp, SourceLocation CmpLoc);
|
|
|
|
|
2007-09-02 10:04:30 +08:00
|
|
|
/// type checking declaration initializers (C99 6.7.8)
|
2009-05-28 00:10:08 +08:00
|
|
|
|
2008-11-05 23:29:30 +08:00
|
|
|
bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType,
|
2009-01-14 23:45:31 +08:00
|
|
|
SourceLocation InitLoc,DeclarationName InitEntity,
|
2009-05-31 04:41:30 +08:00
|
|
|
bool DirectInit);
|
2009-01-29 08:45:39 +08:00
|
|
|
bool CheckInitList(InitListExpr *&InitList, QualType &DeclType);
|
2008-01-11 06:15:12 +08:00
|
|
|
bool CheckForConstantInitializer(Expr *e, QualType t);
|
2007-12-11 06:44:33 +08:00
|
|
|
|
2009-02-03 01:43:21 +08:00
|
|
|
bool CheckValueInitialization(QualType Type, SourceLocation Loc);
|
2008-08-17 04:27:34 +08:00
|
|
|
|
2008-10-29 08:13:59 +08:00
|
|
|
// type checking C++ declaration initializers (C++ [dcl.init]).
|
|
|
|
|
|
|
|
/// ReferenceCompareResult - Expresses the result of comparing two
|
|
|
|
/// types (cv1 T1 and cv2 T2) to determine their compatibility for the
|
|
|
|
/// purposes of initialization by reference (C++ [dcl.init.ref]p4).
|
|
|
|
enum ReferenceCompareResult {
|
|
|
|
/// Ref_Incompatible - The two types are incompatible, so direct
|
|
|
|
/// reference binding is not possible.
|
|
|
|
Ref_Incompatible = 0,
|
|
|
|
/// Ref_Related - The two types are reference-related, which means
|
|
|
|
/// that their unqualified forms (T1 and T2) are either the same
|
|
|
|
/// or T1 is a base class of T2.
|
|
|
|
Ref_Related,
|
|
|
|
/// Ref_Compatible_With_Added_Qualification - The two types are
|
|
|
|
/// reference-compatible with added qualification, meaning that
|
|
|
|
/// they are reference-compatible and the qualifiers on T1 (cv1)
|
|
|
|
/// are greater than the qualifiers on T2 (cv2).
|
|
|
|
Ref_Compatible_With_Added_Qualification,
|
|
|
|
/// Ref_Compatible - The two types are reference-compatible and
|
|
|
|
/// have equivalent qualifiers (cv1 == cv2).
|
|
|
|
Ref_Compatible
|
|
|
|
};
|
|
|
|
|
2008-10-29 10:00:59 +08:00
|
|
|
ReferenceCompareResult CompareReferenceRelationship(QualType T1, QualType T2,
|
|
|
|
bool& DerivedToBase);
|
2008-10-29 08:13:59 +08:00
|
|
|
|
2009-04-17 01:51:27 +08:00
|
|
|
bool CheckReferenceInit(Expr *&simpleInit_or_initList, QualType declType,
|
2008-11-04 03:09:14 +08:00
|
|
|
ImplicitConversionSequence *ICS = 0,
|
2009-01-14 23:45:31 +08:00
|
|
|
bool SuppressUserConversions = false,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool AllowExplicit = false,
|
|
|
|
bool ForceRValue = false);
|
2008-10-29 08:13:59 +08:00
|
|
|
|
2008-08-17 04:27:34 +08:00
|
|
|
/// CheckCastTypes - Check type constraints for casting between types.
|
2008-08-20 11:55:42 +08:00
|
|
|
bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr);
|
2008-01-22 08:55:40 +08:00
|
|
|
|
2007-11-27 15:16:40 +08:00
|
|
|
// CheckVectorCast - check type constraints for vectors.
|
|
|
|
// Since vectors are an extension, there are no C standard reference for this.
|
|
|
|
// We allow casting between vectors and integer datatypes of the same size.
|
2007-11-27 13:51:55 +08:00
|
|
|
// returns true if the cast is invalid
|
|
|
|
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty);
|
|
|
|
|
2008-09-11 08:01:56 +08:00
|
|
|
/// CheckMessageArgumentTypes - Check types in an Obj-C message send.
|
|
|
|
/// \param Method - May be null.
|
|
|
|
/// \param [out] ReturnType - The return type of the send.
|
|
|
|
/// \return true iff there were any incompatible types.
|
2008-09-11 08:50:25 +08:00
|
|
|
bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel,
|
2008-11-24 11:33:13 +08:00
|
|
|
ObjCMethodDecl *Method, bool isClassMessage,
|
2008-09-11 08:01:56 +08:00
|
|
|
SourceLocation lbrac, SourceLocation rbrac,
|
|
|
|
QualType &ReturnType);
|
2008-09-10 10:17:11 +08:00
|
|
|
|
|
|
|
/// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
|
|
|
|
bool CheckCXXBooleanCondition(Expr *&CondExpr);
|
2007-10-17 07:12:48 +08:00
|
|
|
|
2007-08-23 13:46:52 +08:00
|
|
|
/// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
|
|
|
|
/// the specified width and sign. If an overflow occurs, detect it and emit
|
|
|
|
/// the specified diagnostic.
|
|
|
|
void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
|
|
|
|
unsigned NewWidth, bool NewSign,
|
|
|
|
SourceLocation Loc, unsigned DiagID);
|
|
|
|
|
2008-04-07 13:30:13 +08:00
|
|
|
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS,
|
|
|
|
bool ForCompare);
|
|
|
|
|
2008-11-05 00:57:32 +08:00
|
|
|
/// Checks that the Objective-C declaration is declared in the global scope.
|
|
|
|
/// Emits an error and marks the declaration as invalid if it's not declared
|
|
|
|
/// in the global scope.
|
|
|
|
bool CheckObjCDeclScope(Decl *D);
|
|
|
|
|
2007-10-16 04:28:48 +08:00
|
|
|
void InitBuiltinVaListType();
|
2008-06-04 05:01:11 +08:00
|
|
|
|
2008-12-01 03:50:32 +08:00
|
|
|
/// VerifyIntegerConstantExpression - verifies that an expression is an ICE,
|
|
|
|
/// and reports the appropriate diagnostics. Returns false on success.
|
|
|
|
/// Can optionally return the value of the expression.
|
2008-12-07 04:33:04 +08:00
|
|
|
bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0);
|
2008-12-01 10:17:22 +08:00
|
|
|
|
2008-12-07 04:33:04 +08:00
|
|
|
/// VerifyBitField - verifies that a bit field expression is an ICE and has
|
|
|
|
/// the correct width, and that the field type is valid.
|
|
|
|
/// Returns false on success.
|
|
|
|
bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
|
|
|
|
QualType FieldTy, const Expr *BitWidth);
|
2009-01-19 08:08:26 +08:00
|
|
|
|
2007-08-11 04:18:51 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Extra semantic analysis beyond the C type system
|
2007-12-28 13:29:59 +08:00
|
|
|
private:
|
2009-01-19 08:08:26 +08:00
|
|
|
Action::OwningExprResult CheckFunctionCall(FunctionDecl *FDecl,
|
|
|
|
CallExpr *TheCall);
|
2009-05-19 05:05:18 +08:00
|
|
|
|
|
|
|
Action::OwningExprResult CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
|
2009-02-19 01:49:48 +08:00
|
|
|
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
|
|
|
|
unsigned ByteNo) const;
|
2009-02-18 14:01:06 +08:00
|
|
|
bool CheckObjCString(Expr *Arg);
|
2007-12-28 13:29:59 +08:00
|
|
|
bool SemaBuiltinVAStart(CallExpr *TheCall);
|
|
|
|
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
|
2008-05-20 16:23:37 +08:00
|
|
|
bool SemaBuiltinStackAddress(CallExpr *TheCall);
|
2009-05-20 06:10:17 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Used by C++ template instantiation.
|
2009-01-19 08:08:26 +08:00
|
|
|
Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
|
2009-05-20 06:10:17 +08:00
|
|
|
|
|
|
|
private:
|
2008-07-22 06:59:13 +08:00
|
|
|
bool SemaBuiltinPrefetch(CallExpr *TheCall);
|
2009-05-03 12:46:36 +08:00
|
|
|
bool SemaBuiltinObjectSize(CallExpr *TheCall);
|
|
|
|
bool SemaBuiltinLongjmp(CallExpr *TheCall);
|
2009-05-08 14:58:22 +08:00
|
|
|
bool SemaBuiltinAtomicOverloaded(CallExpr *TheCall);
|
2009-03-21 05:35:28 +08:00
|
|
|
bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
|
|
|
|
bool HasVAListArg, unsigned format_idx,
|
|
|
|
unsigned firstDataArg);
|
|
|
|
void CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
|
|
|
|
const CallExpr *TheCall, bool HasVAListArg,
|
2009-02-15 02:57:46 +08:00
|
|
|
unsigned format_idx, unsigned firstDataArg);
|
2009-05-22 02:48:51 +08:00
|
|
|
void CheckNonNullArguments(const NonNullAttr *NonNull,
|
|
|
|
const CallExpr *TheCall);
|
2009-03-21 05:35:28 +08:00
|
|
|
void CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
|
2009-02-15 02:57:46 +08:00
|
|
|
unsigned format_idx, unsigned firstDataArg);
|
2007-08-18 00:46:58 +08:00
|
|
|
void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
|
|
|
|
SourceLocation ReturnLoc);
|
2007-11-25 08:58:00 +08:00
|
|
|
void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
|
2006-11-03 14:42:29 +08:00
|
|
|
};
|
|
|
|
|
2009-02-20 06:01:56 +08:00
|
|
|
|
2009-02-07 09:47:29 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers).
|
|
|
|
template <typename T>
|
|
|
|
class ExprOwningPtr : public Action::ExprArg {
|
|
|
|
public:
|
2009-03-13 00:53:44 +08:00
|
|
|
ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}
|
2009-02-07 09:47:29 +08:00
|
|
|
|
|
|
|
void reset(T* p) { Action::ExprArg::operator=(p); }
|
|
|
|
T* get() const { return static_cast<T*>(Action::ExprArg::get()); }
|
|
|
|
T* take() { return static_cast<T*>(Action::ExprArg::take()); }
|
|
|
|
T* release() { return take(); }
|
|
|
|
|
|
|
|
T& operator*() const { return *get(); }
|
|
|
|
T* operator->() const { return get(); }
|
|
|
|
};
|
2009-05-21 06:33:37 +08:00
|
|
|
|
2006-11-03 14:42:29 +08:00
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|