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-08-29 01:37:35 +08:00
|
|
|
#include "SemaTemplate.h"
|
2009-06-20 07:52:42 +08:00
|
|
|
#include "clang/AST/Attr.h"
|
2009-01-15 06:20:51 +08:00
|
|
|
#include "clang/AST/DeclBase.h"
|
2009-06-20 07:52:42 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
2009-04-25 05:10:55 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2009-06-05 11:43:12 +08:00
|
|
|
#include "clang/AST/DeclTemplate.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-07-01 01:20:14 +08:00
|
|
|
#include <deque>
|
2009-06-23 04:57:11 +08:00
|
|
|
#include <list>
|
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;
|
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
class CodeCompleteConsumer;
|
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-08-11 07:49:36 +08:00
|
|
|
class ParenListExpr;
|
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-10-29 16:12:44 +08:00
|
|
|
class TemplateArgumentLoc;
|
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-05-31 17:31:02 +08:00
|
|
|
class ClassTemplatePartialSpecializationDecl;
|
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;
|
2009-07-04 19:39:00 +08:00
|
|
|
class FunctionProtoType;
|
2009-10-07 01:59:45 +08:00
|
|
|
class CXXBasePaths;
|
2009-05-31 05:05:25 +08:00
|
|
|
class CXXTemporary;
|
2009-11-18 15:57:50 +08:00
|
|
|
class LookupResult;
|
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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
BlockDecl *TheDecl;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// TheScope - This is the scope for the block itself, which contains
|
|
|
|
/// arguments etc.
|
|
|
|
Scope *TheScope;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// ReturnType - This will get set to block result type, by looking at
|
|
|
|
/// return types, if any, in the block body.
|
2009-06-20 07:37:08 +08:00
|
|
|
QualType ReturnType;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// 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-09-09 23:08:12 +08:00
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:01:55 +08:00
|
|
|
/// PrevBlockInfo - If this is nested inside another block, this points
|
|
|
|
/// to the outer block.
|
|
|
|
BlockSemaInfo *PrevBlockInfo;
|
|
|
|
};
|
|
|
|
|
2009-08-19 09:28:17 +08:00
|
|
|
/// \brief Holds a QualType and a DeclaratorInfo* that came out of a declarator
|
|
|
|
/// parsing.
|
|
|
|
///
|
|
|
|
/// LocInfoType is a "transient" type, only needed for passing to/from Parser
|
|
|
|
/// and Sema, when we want to preserve type source info for a parsed type.
|
|
|
|
/// It will not participate in the type system semantics in any way.
|
|
|
|
class LocInfoType : public Type {
|
|
|
|
enum {
|
|
|
|
// The last number that can fit in Type's TC.
|
2009-09-09 23:08:12 +08:00
|
|
|
// Avoids conflict with an existing Type class.
|
2009-08-19 09:28:17 +08:00
|
|
|
LocInfo = (1 << TypeClassBitSize) - 1
|
|
|
|
};
|
|
|
|
|
|
|
|
DeclaratorInfo *DeclInfo;
|
|
|
|
|
|
|
|
LocInfoType(QualType ty, DeclaratorInfo *DInfo)
|
|
|
|
: Type((TypeClass)LocInfo, ty, ty->isDependentType()), DeclInfo(DInfo) {
|
|
|
|
assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
|
|
|
|
}
|
|
|
|
friend class Sema;
|
|
|
|
|
|
|
|
public:
|
|
|
|
QualType getType() const { return getCanonicalTypeInternal(); }
|
|
|
|
DeclaratorInfo *getDeclaratorInfo() const { return DeclInfo; }
|
|
|
|
|
|
|
|
virtual void getAsStringInternal(std::string &Str,
|
|
|
|
const PrintingPolicy &Policy) const;
|
|
|
|
|
|
|
|
static bool classof(const Type *T) {
|
|
|
|
return T->getTypeClass() == (TypeClass)LocInfo;
|
|
|
|
}
|
|
|
|
static bool classof(const LocInfoType *) { return true; }
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
/// \brief Code-completion consumer.
|
|
|
|
CodeCompleteConsumer *CodeCompleter;
|
|
|
|
|
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-09-09 23:08:12 +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
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// ExprTemporaries - This is the stack of temporaries that are created by
|
2009-05-18 02:41:29 +08:00
|
|
|
/// 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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// PureVirtualClassDiagSet - a set of class declarations which we have
|
2009-03-23 04:18:17 +08:00
|
|
|
/// emitted a list of pure virtual functions. Used to prevent emitting the
|
|
|
|
/// same list more than once.
|
|
|
|
llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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;
|
2009-09-09 02:19:27 +08:00
|
|
|
std::vector<DeclarationName> TentativeDefinitionList;
|
2009-04-22 01:11:58 +08:00
|
|
|
|
2009-11-04 10:18:39 +08:00
|
|
|
/// \brief The collection of delayed deprecation warnings.
|
|
|
|
llvm::SmallVector<std::pair<SourceLocation,NamedDecl*>, 8>
|
|
|
|
DelayedDeprecationWarnings;
|
|
|
|
|
|
|
|
/// \brief The depth of the current ParsingDeclaration stack.
|
|
|
|
/// If nonzero, we are currently parsing a declaration (and
|
|
|
|
/// hence should delay deprecation warnings).
|
|
|
|
unsigned ParsingDeclDepth;
|
|
|
|
|
2009-07-30 11:15:39 +08:00
|
|
|
/// WeakUndeclaredIdentifiers - Identifiers contained in
|
|
|
|
/// #pragma weak before declared. rare. may alias another
|
|
|
|
/// identifier, declared or undeclared
|
|
|
|
class WeakInfo {
|
|
|
|
IdentifierInfo *alias; // alias (optional)
|
|
|
|
SourceLocation loc; // for diagnostics
|
|
|
|
bool used; // identifier later declared?
|
|
|
|
public:
|
|
|
|
WeakInfo()
|
|
|
|
: alias(0), loc(SourceLocation()), used(false) {}
|
|
|
|
WeakInfo(IdentifierInfo *Alias, SourceLocation Loc)
|
|
|
|
: alias(Alias), loc(Loc), used(false) {}
|
|
|
|
inline IdentifierInfo * getAlias() const { return alias; }
|
|
|
|
inline SourceLocation getLocation() const { return loc; }
|
|
|
|
void setUsed(bool Used=true) { used = Used; }
|
|
|
|
inline bool getUsed() { return used; }
|
|
|
|
bool operator==(WeakInfo RHS) const {
|
|
|
|
return alias == RHS.getAlias() && loc == RHS.getLocation();
|
|
|
|
}
|
|
|
|
bool operator!=(WeakInfo RHS) const { return !(*this == RHS); }
|
|
|
|
};
|
|
|
|
llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers;
|
|
|
|
|
2009-07-31 10:52:19 +08:00
|
|
|
/// WeakTopLevelDecl - Translation-unit scoped declarations generated by
|
|
|
|
/// #pragma weak during processing of other Decls.
|
|
|
|
/// I couldn't figure out a clean way to generate these in-line, so
|
|
|
|
/// we store them here and handle separately -- which is a hack.
|
|
|
|
/// It would be best to refactor this.
|
|
|
|
llvm::SmallVector<Decl*,2> WeakTopLevelDecl;
|
|
|
|
|
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
|
|
|
|
2009-09-16 06:30:29 +08:00
|
|
|
/// \brief The C++ "std" namespace, where the standard library resides.
|
2008-11-11 19:37:55 +08:00
|
|
|
NamespaceDecl *StdNamespace;
|
2008-12-04 04:26:15 +08:00
|
|
|
|
2009-09-16 06:30:29 +08:00
|
|
|
/// \brief The C++ "std::bad_alloc" class, which is defined by the C++
|
|
|
|
/// standard library.
|
|
|
|
CXXRecordDecl *StdBadAlloc;
|
|
|
|
|
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
|
|
|
|
2009-06-23 04:57:11 +08:00
|
|
|
/// The current expression evaluation context.
|
|
|
|
ExpressionEvaluationContext ExprEvalContext;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
typedef std::vector<std::pair<SourceLocation, Decl *> >
|
2009-06-23 04:57:11 +08:00
|
|
|
PotentiallyReferencedDecls;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-23 04:57:11 +08:00
|
|
|
/// A stack of declarations, each element of which is a set of declarations
|
|
|
|
/// that will be marked as referenced if the corresponding potentially
|
|
|
|
/// potentially evaluated expression is potentially evaluated. Each element
|
|
|
|
/// in the stack corresponds to a PotentiallyPotentiallyEvaluated expression
|
|
|
|
/// evaluation context.
|
|
|
|
std::list<PotentiallyReferencedDecls> PotentiallyReferencedDeclStack;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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-08-19 09:28:17 +08:00
|
|
|
llvm::BumpPtrAllocator BumpAlloc;
|
|
|
|
|
2009-06-14 16:02:22 +08:00
|
|
|
/// \brief The number of SFINAE diagnostics that have been trapped.
|
|
|
|
unsigned NumSFINAEErrors;
|
|
|
|
|
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
|
2009-09-09 23:08:12 +08:00
|
|
|
/// differing signatures across classes. In Cocoa, this happens to be
|
2007-10-14 08:58:41 +08:00
|
|
|
/// extremely uncommon (only 1% of selectors are "overloaded").
|
2009-04-25 05:10:55 +08:00
|
|
|
MethodPool InstanceMethodPool;
|
|
|
|
MethodPool FactoryMethodPool;
|
2009-09-09 23:08:12 +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,
|
2009-11-13 16:58:20 +08:00
|
|
|
bool CompleteTranslationUnit = true,
|
|
|
|
CodeCompleteConsumer *CompletionConsumer = 0);
|
2009-02-17 09:09:29 +08:00
|
|
|
~Sema() {
|
|
|
|
if (PackContext) FreePackedContext();
|
|
|
|
}
|
2009-09-09 23:08:12 +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) { }
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
explicit SemaDiagnosticBuilder(Sema &SemaRef)
|
2009-06-14 15:33:30 +08:00
|
|
|
: DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { }
|
|
|
|
|
2009-03-21 06:48:49 +08:00
|
|
|
~SemaDiagnosticBuilder();
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Emit a diagnostic.
|
|
|
|
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
|
2009-06-14 15:33:30 +08:00
|
|
|
if (isSFINAEContext() && Diagnostic::isBuiltinSFINAEDiag(DiagID)) {
|
|
|
|
// If we encountered an error during template argument
|
|
|
|
// deduction, and that error is one of the SFINAE errors,
|
2009-06-14 16:02:22 +08:00
|
|
|
// suppress the diagnostic.
|
2009-06-16 00:52:15 +08:00
|
|
|
++NumSFINAEErrors;
|
2009-09-26 07:53:26 +08:00
|
|
|
Diags.setLastDiagnosticIgnored();
|
2009-06-16 00:52:15 +08:00
|
|
|
return SemaDiagnosticBuilder(*this);
|
2009-06-14 15:33:30 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2009-08-27 06:33:56 +08:00
|
|
|
/// \brief Emit a partial diagnostic.
|
|
|
|
SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD);
|
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
|
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;
|
|
|
|
}
|
2009-07-31 10:52:19 +08:00
|
|
|
|
|
|
|
/// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
|
|
|
|
llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
|
2009-09-09 23:08:12 +08:00
|
|
|
|
Add support for retrieving the Doxygen comment associated with a given
declaration in the AST.
The new ASTContext::getCommentForDecl function searches for a comment
that is attached to the given declaration, and returns that comment,
which may be composed of several comment blocks.
Comments are always available in an AST. However, to avoid harming
performance, we don't actually parse the comments. Rather, we keep the
source ranges of all of the comments within a large, sorted vector,
then lazily extract comments via a binary search in that vector only
when needed (which never occurs in a "normal" compile).
Comments are written to a precompiled header/AST file as a blob of
source ranges. That blob is only lazily loaded when one requests a
comment for a declaration (this never occurs in a "normal" compile).
The indexer testbed now supports comment extraction. When the
-point-at location points to a declaration with a Doxygen-style
comment, the indexer testbed prints the associated comment
block(s). See test/Index/comments.c for an example.
Some notes:
- We don't actually attempt to parse the comment blocks themselves,
beyond identifying them as Doxygen comment blocks to associate them
with a declaration.
- We won't find comment blocks that aren't adjacent to the
declaration, because we start our search based on the location of
the declaration.
- We don't go through the necessary hops to find, for example,
whether some redeclaration of a declaration has comments when our
current declaration does not. Similarly, we don't attempt to
associate a \param Foo marker in a function body comment with the
parameter named Foo (although that is certainly possible).
- Verification of my "no performance impact" claims is still "to be
done".
llvm-svn: 74704
2009-07-03 01:08:52 +08:00
|
|
|
virtual void ActOnComment(SourceRange Comment);
|
|
|
|
|
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);
|
2008-06-29 08:50:08 +08:00
|
|
|
void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL);
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType BuildPointerType(QualType T, unsigned Quals,
|
2009-02-28 08:25:32 +08:00
|
|
|
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,
|
2009-07-06 23:59:29 +08:00
|
|
|
SourceRange Brackets, DeclarationName Entity);
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType BuildExtVectorType(QualType T, ExprArg ArraySize,
|
2009-06-18 05:51:59 +08:00
|
|
|
SourceLocation AttrLoc);
|
2009-02-28 09:04:19 +08:00
|
|
|
QualType BuildFunctionType(QualType T,
|
|
|
|
QualType *ParamTypes, unsigned NumParamTypes,
|
|
|
|
bool Variadic, unsigned Quals,
|
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType BuildMemberPointerType(QualType T, QualType Class,
|
|
|
|
unsigned Quals, SourceLocation Loc,
|
2009-06-10 06:17:39 +08:00
|
|
|
DeclarationName Entity);
|
2009-06-13 06:56:54 +08:00
|
|
|
QualType BuildBlockPointerType(QualType T, unsigned Quals,
|
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
2009-08-19 09:27:57 +08:00
|
|
|
QualType GetTypeForDeclarator(Declarator &D, Scope *S,
|
|
|
|
DeclaratorInfo **DInfo = 0,
|
2009-10-26 05:45:37 +08:00
|
|
|
TagDecl **OwnedDecl = 0);
|
|
|
|
DeclaratorInfo *GetDeclaratorInfoForDeclarator(Declarator &D, QualType T);
|
2009-08-19 09:28:17 +08:00
|
|
|
/// \brief Create a LocInfoType to hold the given QualType and DeclaratorInfo.
|
|
|
|
QualType CreateLocInfoType(QualType T, DeclaratorInfo *DInfo);
|
2008-11-18 06:58:34 +08:00
|
|
|
DeclarationName GetNameForDeclarator(Declarator &D);
|
2009-11-04 00:56:39 +08:00
|
|
|
DeclarationName GetNameFromUnqualifiedId(UnqualifiedId &Name);
|
2009-08-19 09:28:28 +08:00
|
|
|
static QualType GetTypeFromParser(TypeTy *Ty, DeclaratorInfo **DInfo = 0);
|
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);
|
2009-07-04 19:39:00 +08:00
|
|
|
bool CheckEquivalentExceptionSpec(
|
|
|
|
const FunctionProtoType *Old, SourceLocation OldLoc,
|
|
|
|
const FunctionProtoType *New, SourceLocation NewLoc);
|
2009-10-15 00:09:29 +08:00
|
|
|
bool CheckEquivalentExceptionSpec(
|
|
|
|
const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
|
2009-10-11 17:03:14 +08:00
|
|
|
const FunctionProtoType *Old, SourceLocation OldLoc,
|
|
|
|
const FunctionProtoType *New, SourceLocation NewLoc);
|
2009-10-15 00:09:29 +08:00
|
|
|
bool CheckExceptionSpecSubset(
|
|
|
|
const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
|
2009-07-08 04:29:57 +08:00
|
|
|
const FunctionProtoType *Superset, SourceLocation SuperLoc,
|
|
|
|
const FunctionProtoType *Subset, SourceLocation SubLoc);
|
2009-10-15 00:09:29 +08:00
|
|
|
bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID,
|
2009-10-11 17:03:14 +08:00
|
|
|
const FunctionProtoType *Target, SourceLocation TargetLoc,
|
|
|
|
const FunctionProtoType *Source, SourceLocation SourceLoc);
|
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-08-27 06:33:56 +08:00
|
|
|
bool RequireCompleteType(SourceLocation Loc, QualType T,
|
2009-10-10 07:51:55 +08:00
|
|
|
const PartialDiagnostic &PD,
|
|
|
|
std::pair<SourceLocation,
|
|
|
|
PartialDiagnostic> Note =
|
|
|
|
std::make_pair(SourceLocation(), PDiag()));
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-19 08:39:20 +08:00
|
|
|
QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T);
|
|
|
|
|
2009-06-30 06:58:55 +08:00
|
|
|
QualType BuildTypeofExprType(Expr *E);
|
|
|
|
QualType BuildDecltypeType(Expr *E);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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
|
2009-09-09 23:08:12 +08:00
|
|
|
/// 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-09-09 23:08:12 +08:00
|
|
|
|
2009-03-30 00:50:03 +08:00
|
|
|
DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
|
2009-08-27 02:27:52 +08:00
|
|
|
Scope *S, const CXXScopeSpec *SS,
|
2009-11-21 06:03:38 +08:00
|
|
|
bool isClassName = false,
|
|
|
|
TypeTy *ObjectType = 0);
|
2009-04-13 05:49:30 +08:00
|
|
|
virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
|
2009-10-14 07:27:22 +08:00
|
|
|
virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
|
|
|
|
SourceLocation IILoc,
|
|
|
|
Scope *S,
|
|
|
|
const CXXScopeSpec *SS,
|
|
|
|
TypeTy *&SuggestedType);
|
|
|
|
|
2009-03-30 00:50:03 +08:00
|
|
|
virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
|
2009-06-24 07:11:28 +08:00
|
|
|
return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
|
2008-12-16 07:53:10 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
DeclPtrTy HandleDeclarator(Scope *S, Declarator &D,
|
2009-06-24 07:11:28 +08:00
|
|
|
MultiTemplateParamsArg TemplateParameterLists,
|
|
|
|
bool IsFunctionDefinition);
|
2009-11-19 06:49:29 +08:00
|
|
|
void RegisterLocallyScopedExternCDecl(NamedDecl *ND,
|
|
|
|
const LookupResult &Previous,
|
2009-03-02 08:19:53 +08:00
|
|
|
Scope *S);
|
2009-04-08 03:37:57 +08:00
|
|
|
void DiagnoseFunctionSpecifiers(Declarator& D);
|
2009-11-19 06:49:29 +08:00
|
|
|
bool CheckRedeclaration(DeclContext *DC,
|
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
unsigned Diagnostic);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
2009-08-19 09:27:57 +08:00
|
|
|
QualType R, DeclaratorInfo *DInfo,
|
2009-11-19 06:49:29 +08:00
|
|
|
LookupResult &Previous, bool &Redeclaration);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
2009-08-19 09:27:57 +08:00
|
|
|
QualType R, DeclaratorInfo *DInfo,
|
2009-11-19 06:49:29 +08:00
|
|
|
LookupResult &Previous,
|
2009-07-23 01:18:37 +08:00
|
|
|
MultiTemplateParamsArg TemplateParamLists,
|
2009-02-17 01:45:42 +08:00
|
|
|
bool &Redeclaration);
|
2009-11-19 06:49:29 +08:00
|
|
|
void CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous,
|
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-08-19 09:27:57 +08:00
|
|
|
QualType R, DeclaratorInfo *DInfo,
|
2009-11-19 06:49:29 +08:00
|
|
|
LookupResult &Previous,
|
2009-06-24 07:11:28 +08:00
|
|
|
MultiTemplateParamsArg TemplateParamLists,
|
2009-02-24 09:23:02 +08:00
|
|
|
bool IsFunctionDefinition,
|
2009-04-25 16:06:05 +08:00
|
|
|
bool &Redeclaration);
|
2009-11-19 05:51:29 +08:00
|
|
|
void AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
|
2009-11-19 06:49:29 +08:00
|
|
|
void CheckFunctionDeclaration(FunctionDecl *NewFD, LookupResult &Previous,
|
2009-10-14 00:30:37 +08:00
|
|
|
bool IsExplicitSpecialization,
|
2009-09-09 23:08:12 +08:00
|
|
|
bool &Redeclaration,
|
2009-03-24 07:06:20 +08:00
|
|
|
bool &OverloadableAttrRequired);
|
2009-07-24 11:03:21 +08:00
|
|
|
void CheckMain(FunctionDecl *FD);
|
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-09-09 23:08:12 +08:00
|
|
|
virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
|
2009-06-13 00:51:40 +08:00
|
|
|
SourceLocation EqualLoc,
|
|
|
|
SourceLocation ArgLoc);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnParamDefaultArgumentError(DeclPtrTy param);
|
2009-08-25 10:29:20 +08:00
|
|
|
bool SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
|
|
|
|
SourceLocation EqualLoc);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-13 00:51:40 +08:00
|
|
|
// Contains the locations of the beginning of unparsed default
|
|
|
|
// argument locations.
|
|
|
|
llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs;
|
|
|
|
|
2009-08-16 13:13:48 +08:00
|
|
|
virtual void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init);
|
2009-03-29 03:18:32 +08:00
|
|
|
void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit);
|
2009-07-11 08:34:39 +08:00
|
|
|
void ActOnUninitializedDecl(DeclPtrTy dcl, bool TypeContainsUndeducedAuto);
|
2009-03-29 03:18:32 +08:00
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
|
2009-06-20 07:52:42 +08:00
|
|
|
/// \brief Diagnose any unused parameters in the given sequence of
|
|
|
|
/// ParmVarDecl pointers.
|
|
|
|
template<typename InputIterator>
|
|
|
|
void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) {
|
|
|
|
for (; Param != ParamEnd; ++Param) {
|
2009-09-09 23:08:12 +08:00
|
|
|
if (!(*Param)->isUsed() && (*Param)->getDeclName() &&
|
2009-06-30 10:34:44 +08:00
|
|
|
!(*Param)->template hasAttr<UnusedAttr>())
|
2009-06-20 07:52:42 +08:00
|
|
|
Diag((*Param)->getLocation(), diag::warn_unused_parameter)
|
|
|
|
<< (*Param)->getDeclName();
|
|
|
|
}
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-01-07 08:43:41 +08:00
|
|
|
bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
|
|
|
|
RecordDecl *AnonRecord);
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
2009-03-29 03:18:32 +08:00
|
|
|
RecordDecl *Record);
|
2009-01-07 08:43:41 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
bool isAcceptableTagRedeclaration(const TagDecl *Previous,
|
2009-05-15 00:41:31 +08:00
|
|
|
TagDecl::TagKind NewTag,
|
|
|
|
SourceLocation NewTagLoc,
|
|
|
|
const IdentifierInfo &Name);
|
2009-05-04 01:18:57 +08:00
|
|
|
|
2009-07-31 10:45:11 +08:00
|
|
|
virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
2009-03-29 03:18:32 +08:00
|
|
|
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,
|
2009-07-23 07:48:44 +08:00
|
|
|
MultiTemplateParamsArg TemplateParameterLists,
|
2009-09-11 12:59:25 +08:00
|
|
|
bool &OwnedDecl, bool &IsDependent);
|
|
|
|
|
|
|
|
virtual TypeResult ActOnDependentTag(Scope *S,
|
|
|
|
unsigned TagSpec,
|
|
|
|
TagUseKind TUK,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
SourceLocation TagLoc,
|
|
|
|
SourceLocation NameLoc);
|
2009-09-09 23:08:12 +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-08-19 09:27:57 +08:00
|
|
|
FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
|
2009-09-09 23:08:12 +08:00
|
|
|
DeclaratorInfo *DInfo,
|
2009-03-12 02:59:21 +08:00
|
|
|
RecordDecl *Record, SourceLocation Loc,
|
|
|
|
bool Mutable, Expr *BitfieldWidth,
|
2009-07-14 22:58:18 +08:00
|
|
|
SourceLocation TSSL,
|
2009-03-12 04:50:30 +08:00
|
|
|
AccessSpecifier AS, NamedDecl *PrevDecl,
|
2009-03-12 02:59:21 +08:00
|
|
|
Declarator *D = 0);
|
2009-07-23 02:25:24 +08:00
|
|
|
|
|
|
|
enum CXXSpecialMember {
|
|
|
|
CXXDefaultConstructor = 0,
|
|
|
|
CXXCopyConstructor = 1,
|
|
|
|
CXXCopyAssignment = 2,
|
|
|
|
CXXDestructor = 3
|
|
|
|
};
|
|
|
|
void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
|
2009-06-06 02:16:35 +08:00
|
|
|
DeclPtrTy IntfDecl,
|
2009-03-29 03:18:32 +08:00
|
|
|
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-07-14 11:17:52 +08:00
|
|
|
virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl,
|
|
|
|
SourceLocation RBraceLoc);
|
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-08-08 22:36:57 +08:00
|
|
|
DeclPtrTy *Elements, unsigned NumElements,
|
|
|
|
Scope *S, AttributeList *Attr);
|
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();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-18 07:15:40 +08:00
|
|
|
/// EnterDeclaratorContext - Used when we must lookup names in the context
|
|
|
|
/// of a declarator's nested name specifier.
|
|
|
|
void EnterDeclaratorContext(Scope *S, DeclContext *DC);
|
|
|
|
void ExitDeclaratorContext(Scope *S);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-09 01:45:02 +08:00
|
|
|
DeclContext *getFunctionLevelDeclContext();
|
2009-09-09 23:08:12 +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();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-12-05 07:50:19 +08:00
|
|
|
/// 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.
|
2009-09-01 06:39:49 +08:00
|
|
|
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
|
2008-04-12 08:47:19 +08:00
|
|
|
|
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.
|
2009-09-28 08:47:05 +08:00
|
|
|
bool isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S = 0);
|
2008-09-10 05:18:04 +08:00
|
|
|
|
2009-09-01 06:39:49 +08:00
|
|
|
/// Finds the scope corresponding to the given decl context, if it
|
|
|
|
/// happens to be an enclosing scope. Otherwise return NULL.
|
|
|
|
Scope *getScopeForDeclContext(Scope *S, DeclContext *DC) {
|
2009-09-02 09:07:03 +08:00
|
|
|
DeclContext *TargetDC = DC->getPrimaryContext();
|
2009-09-01 06:39:49 +08:00
|
|
|
do {
|
2009-09-02 09:07:03 +08:00
|
|
|
if (DeclContext *ScopeDC = (DeclContext*) S->getEntity())
|
|
|
|
if (ScopeDC->getPrimaryContext() == TargetDC)
|
|
|
|
return S;
|
2009-09-01 06:39:49 +08:00
|
|
|
} while ((S = S->getParent()));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-16 03:12:21 +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.
|
|
|
|
OR_Ambiguous, ///< Ambiguous candidates found.
|
|
|
|
OR_Deleted ///< Overload resoltuion refers to a deleted function.
|
|
|
|
};
|
|
|
|
|
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-10-24 16:00:42 +08:00
|
|
|
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
|
|
|
|
DeclaratorInfo *DInfo);
|
2009-11-19 06:49:29 +08:00
|
|
|
void MergeTypeDefDecl(TypedefDecl *New, LookupResult &OldDecls);
|
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-11-19 06:49:29 +08:00
|
|
|
void MergeVarDecl(VarDecl *New, LookupResult &OldDecls);
|
2009-02-17 01:45:42 +08:00
|
|
|
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
|
2008-10-22 00:13:35 +08:00
|
|
|
|
|
|
|
/// C++ Overloading.
|
2009-11-19 06:49:29 +08:00
|
|
|
bool IsOverload(FunctionDecl *New, LookupResult &OldDecls,
|
|
|
|
NamedDecl *&OldDecl);
|
|
|
|
bool IsOverload(FunctionDecl *New, FunctionDecl *Old);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
ImplicitConversionSequence
|
2009-08-28 01:14:02 +08:00
|
|
|
TryImplicitConversion(Expr* From, QualType ToType,
|
2009-08-28 01:24:15 +08:00
|
|
|
bool SuppressUserConversions,
|
|
|
|
bool AllowExplicit,
|
2009-08-28 23:33:32 +08:00
|
|
|
bool ForceRValue,
|
2009-10-02 04:39:51 +08:00
|
|
|
bool InOverloadResolution,
|
|
|
|
bool UserCast = false);
|
2009-08-28 23:33:32 +08:00
|
|
|
bool IsStandardConversion(Expr *From, QualType ToType,
|
|
|
|
bool InOverloadResolution,
|
2008-11-01 00:23:19 +08:00
|
|
|
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,
|
2009-08-28 23:33:32 +08:00
|
|
|
bool InOverloadResolution,
|
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);
|
2009-11-15 05:15:49 +08:00
|
|
|
bool CheckPointerConversion(Expr *From, QualType ToType,
|
|
|
|
CastExpr::CastKind &Kind,
|
|
|
|
bool IgnoreBaseAccess);
|
2009-01-26 03:43:20 +08:00
|
|
|
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
|
2009-09-25 12:25:58 +08:00
|
|
|
bool InOverloadResolution,
|
2009-01-26 03:43:20 +08:00
|
|
|
QualType &ConvertedType);
|
2009-08-23 07:33:40 +08:00
|
|
|
bool CheckMemberPointerConversion(Expr *From, QualType ToType,
|
2009-11-15 05:15:49 +08:00
|
|
|
CastExpr::CastKind &Kind,
|
|
|
|
bool IgnoreBaseAccess);
|
2008-10-22 07:43:52 +08:00
|
|
|
bool IsQualificationConversion(QualType FromType, QualType ToType);
|
2009-09-16 03:12:21 +08:00
|
|
|
OverloadingResult IsUserDefinedConversion(Expr *From, QualType ToType,
|
2009-01-14 23:45:31 +08:00
|
|
|
UserDefinedConversionSequence& User,
|
2009-09-15 08:10:11 +08:00
|
|
|
OverloadCandidateSet& Conversions,
|
2009-01-31 07:27:23 +08:00
|
|
|
bool AllowConversionFunctions,
|
2009-10-02 04:39:51 +08:00
|
|
|
bool AllowExplicit, bool ForceRValue,
|
|
|
|
bool UserCast = false);
|
2009-11-19 02:26:29 +08:00
|
|
|
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
|
2009-09-23 04:24:30 +08:00
|
|
|
|
2008-10-22 00:13:35 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
ImplicitConversionSequence::CompareKind
|
2008-10-22 00:13:35 +08:00
|
|
|
CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
|
|
|
|
const ImplicitConversionSequence& ICS2);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
ImplicitConversionSequence::CompareKind
|
2008-10-22 00:13:35 +08:00
|
|
|
CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
|
|
|
|
const StandardConversionSequence& SCS2);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
ImplicitConversionSequence::CompareKind
|
2008-10-22 22:17:15 +08:00
|
|
|
CompareQualificationConversions(const StandardConversionSequence& SCS1,
|
|
|
|
const StandardConversionSequence& SCS2);
|
|
|
|
|
2008-10-23 08:40:37 +08:00
|
|
|
ImplicitConversionSequence::CompareKind
|
|
|
|
CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
|
|
|
|
const StandardConversionSequence& SCS2);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
ImplicitConversionSequence
|
2008-11-04 03:09:14 +08:00
|
|
|
TryCopyInitialization(Expr* From, QualType ToType,
|
2009-08-28 01:37:39 +08:00
|
|
|
bool SuppressUserConversions, bool ForceRValue,
|
|
|
|
bool InOverloadResolution);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-07-30 03:40:11 +08:00
|
|
|
bool PerformObjectMemberConversion(Expr *&From, NamedDecl *Member);
|
2009-01-14 23:45:31 +08:00
|
|
|
|
2009-08-08 06:18:02 +08:00
|
|
|
// Members have to be NamespaceDecl* or TranslationUnitDecl*.
|
|
|
|
// TODO: make this is a typesafe union.
|
|
|
|
typedef llvm::SmallPtrSet<DeclContext *, 16> AssociatedNamespaceSet;
|
|
|
|
|
2009-06-28 05:05:07 +08:00
|
|
|
typedef llvm::SmallPtrSet<AnyFunctionDecl, 16> FunctionSet;
|
2009-03-14 02:40:31 +08:00
|
|
|
typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
void AddOverloadCandidate(FunctionDecl *Function,
|
2008-10-22 00:13:35 +08:00
|
|
|
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,
|
2009-09-22 23:41:20 +08:00
|
|
|
bool ForceRValue = false,
|
|
|
|
bool PartialOverloading = false);
|
2009-03-14 02:40:31 +08:00
|
|
|
void AddFunctionCandidates(const FunctionSet &Functions,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversions = false);
|
2009-11-17 15:50:12 +08:00
|
|
|
void AddMethodCandidate(NamedDecl *Decl,
|
|
|
|
Expr *Object, Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversion = false,
|
|
|
|
bool ForceRValue = 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);
|
2009-08-21 08:16:32 +08:00
|
|
|
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
|
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-08-21 08:16:32 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
Expr *Object, Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversions = false,
|
|
|
|
bool ForceRValue = false);
|
2009-06-26 06:08:12 +08:00
|
|
|
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
|
2009-07-01 07:57:56 +08:00
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-07-01 07:57:56 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
2009-06-26 06:08:12 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversions = false,
|
|
|
|
bool ForceRValue = false);
|
2008-11-08 06:36:19 +08:00
|
|
|
void AddConversionCandidate(CXXConversionDecl *Conversion,
|
|
|
|
Expr *From, QualType ToType,
|
|
|
|
OverloadCandidateSet& CandidateSet);
|
2009-08-22 07:19:43 +08:00
|
|
|
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
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());
|
2009-09-09 23:08:12 +08:00
|
|
|
void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
|
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
|
|
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
|
2009-10-22 07:19:44 +08:00
|
|
|
SourceLocation OpLoc,
|
2009-09-09 23:08:12 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
2008-11-19 23:42:04 +08:00
|
|
|
OverloadCandidateSet& CandidateSet);
|
2009-02-04 08:32:51 +08:00
|
|
|
void AddArgumentDependentLookupCandidates(DeclarationName Name,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-09-22 23:41:20 +08:00
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-09-22 23:41:20 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool PartialOverloading = false);
|
2008-10-22 00:13:35 +08:00
|
|
|
bool isBetterOverloadCandidate(const OverloadCandidate& Cand1,
|
|
|
|
const OverloadCandidate& Cand2);
|
|
|
|
OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet,
|
2009-06-20 07:52:42 +08:00
|
|
|
SourceLocation Loc,
|
2008-10-22 00:13:35 +08:00
|
|
|
OverloadCandidateSet::iterator& Best);
|
|
|
|
void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
|
2009-10-09 08:13:15 +08:00
|
|
|
bool OnlyViable,
|
2009-10-13 04:11:40 +08:00
|
|
|
const char *Opc=0,
|
2009-10-09 08:13:15 +08:00
|
|
|
SourceLocation Loc=SourceLocation());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-11 04:40:00 +08:00
|
|
|
FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
|
|
|
|
bool Complain);
|
2009-10-22 01:16:23 +08:00
|
|
|
Expr *FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn);
|
2008-11-11 04:40:00 +08:00
|
|
|
|
2009-11-21 16:51:07 +08:00
|
|
|
void AddOverloadedCallCandidates(llvm::SmallVectorImpl<NamedDecl*>& Callees,
|
2009-09-22 23:41:20 +08:00
|
|
|
DeclarationName &UnqualifiedName,
|
2009-11-21 17:38:42 +08:00
|
|
|
bool ArgumentDependentLookup,
|
2009-09-22 23:41:20 +08:00
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-09-22 23:41:20 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet &CandidateSet,
|
|
|
|
bool PartialOverloading = false);
|
|
|
|
|
2009-11-21 16:51:07 +08:00
|
|
|
FunctionDecl *ResolveOverloadedCallFn(Expr *Fn,
|
|
|
|
llvm::SmallVectorImpl<NamedDecl*> &Fns,
|
2009-02-04 23:01:18 +08:00
|
|
|
DeclarationName UnqualifiedName,
|
2009-07-01 07:57:56 +08:00
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-07-01 07:57:56 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
2008-11-26 14:01:48 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation *CommaLocs,
|
2009-02-04 08:32:51 +08:00
|
|
|
SourceLocation RParenLoc,
|
2009-11-21 17:38:42 +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);
|
|
|
|
|
2009-10-30 04:17:01 +08:00
|
|
|
OwningExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
|
|
|
|
SourceLocation RLoc,
|
|
|
|
ExprArg Base,ExprArg Idx);
|
|
|
|
|
2008-12-22 13:46:06 +08:00
|
|
|
ExprResult
|
|
|
|
BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation LParenLoc, Expr **Args,
|
2008-12-22 13:46:06 +08:00
|
|
|
unsigned NumArgs, SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
2009-09-09 23:08:12 +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,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation *CommaLocs,
|
2008-11-20 05:05:33 +08:00
|
|
|
SourceLocation RParenLoc);
|
2008-10-22 00:13:35 +08:00
|
|
|
|
2009-08-06 11:17:00 +08:00
|
|
|
OwningExprResult BuildOverloadedArrowExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation OpLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-10-10 07:51:55 +08:00
|
|
|
/// CheckCallReturnType - Checks that a call expression's return type is
|
|
|
|
/// complete. Returns true on failure. The location passed in is the location
|
|
|
|
/// that best represents the call.
|
|
|
|
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
|
|
|
|
CallExpr *CE, FunctionDecl *FD);
|
|
|
|
|
2009-07-29 06:04:01 +08:00
|
|
|
/// Helpers for dealing with blocks and functions.
|
2009-07-23 07:56:57 +08:00
|
|
|
void CheckFallThroughForFunctionDef(Decl *D, Stmt *Body);
|
2009-07-29 06:04:01 +08:00
|
|
|
void CheckFallThroughForBlock(QualType BlockTy, Stmt *Body);
|
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);
|
2009-07-23 07:56:57 +08:00
|
|
|
enum ControlFlowKind { NeverFallThrough = 0, MaybeFallThrough = 1,
|
2009-10-27 09:59:05 +08:00
|
|
|
AlwaysFallThrough = 2, NeverFallThroughOrReturn = 3 };
|
2009-07-23 07:56:57 +08:00
|
|
|
ControlFlowKind CheckFallThrough(Stmt *);
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
/// and LookupQualifiedName, which performs qualified name lookup.
|
2009-01-15 06:20:51 +08:00
|
|
|
///
|
|
|
|
/// 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
|
2009-09-09 23:08:12 +08:00
|
|
|
/// are outside of the current scope unless they have linkage. See
|
2009-04-24 07:18:26 +08:00
|
|
|
/// 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
|
|
|
};
|
|
|
|
|
2009-11-18 15:57:50 +08:00
|
|
|
enum RedeclarationKind {
|
|
|
|
NotForRedeclaration,
|
|
|
|
ForRedeclaration
|
2009-01-15 06:20:51 +08:00
|
|
|
};
|
|
|
|
|
2009-02-04 03:21:40 +08:00
|
|
|
private:
|
2009-11-17 10:14:36 +08:00
|
|
|
bool CppLookupName(LookupResult &R, Scope *S);
|
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
|
2009-02-05 00:44:47 +08:00
|
|
|
case Sema::LookupOperatorName:
|
2009-09-09 23:08:12 +08:00
|
|
|
return D->isInIdentifierNamespace(IDNS) &&
|
2009-02-05 00:44:47 +08:00
|
|
|
!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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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::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
|
|
|
}
|
2009-09-09 23:08:12 +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-10-10 05:13:30 +08:00
|
|
|
/// \brief Look up a name, looking for a single declaration. Return
|
|
|
|
/// null if no unambiguous results were found.
|
|
|
|
///
|
|
|
|
/// It is preferable to use the elaborated form and explicitly handle
|
|
|
|
/// ambiguity and overloaded.
|
|
|
|
NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
|
|
|
|
LookupNameKind NameKind,
|
2009-11-18 15:57:50 +08:00
|
|
|
RedeclarationKind Redecl
|
|
|
|
= NotForRedeclaration);
|
2009-10-10 05:13:30 +08:00
|
|
|
bool LookupName(LookupResult &R, Scope *S,
|
2009-11-17 10:14:36 +08:00
|
|
|
bool AllowBuiltinCreation = false);
|
|
|
|
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx);
|
2009-10-10 05:13:30 +08:00
|
|
|
bool LookupParsedName(LookupResult &R, Scope *S, const CXXScopeSpec *SS,
|
|
|
|
bool AllowBuiltinCreation = false,
|
|
|
|
bool EnteringContext = false);
|
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
|
|
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType T1, QualType T2,
|
2009-03-13 08:33:25 +08:00
|
|
|
FunctionSet &Functions);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-10-24 03:23:15 +08:00
|
|
|
void ArgumentDependentLookup(DeclarationName Name, bool Operator,
|
2009-03-13 08:33:25 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
FunctionSet &Functions);
|
|
|
|
|
2009-02-04 08:32:51 +08:00
|
|
|
void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
|
|
|
|
AssociatedNamespaceSet &AssociatedNamespaces,
|
2009-08-08 06:18:02 +08:00
|
|
|
AssociatedClassSet &AssociatedClasses);
|
2009-02-04 08:32:51 +08:00
|
|
|
|
2009-11-17 10:14:36 +08:00
|
|
|
bool DiagnoseAmbiguousLookup(LookupResult &Result);
|
2009-01-15 06:20:51 +08:00
|
|
|
//@}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id);
|
2009-09-09 23:08:12 +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.
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
// Decl attributes - this routine is the top level dispatcher.
|
2009-06-18 05:51:59 +08:00
|
|
|
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
|
|
|
|
void ProcessDeclAttributeList(Scope *S, 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);
|
2008-11-11 19:37:55 +08:00
|
|
|
|
2009-01-13 03:55:42 +08:00
|
|
|
bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl,
|
2009-02-27 03:11:32 +08:00
|
|
|
ObjCInterfaceDecl *IDecl);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-10-03 05:43:37 +08:00
|
|
|
/// CheckImplementationIvars - This routine checks if the instance variables
|
2009-09-09 23:08:12 +08:00
|
|
|
/// 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);
|
2009-09-09 23:08:12 +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.
|
2009-09-09 23:08:12 +08:00
|
|
|
void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
|
|
|
|
ObjCContainerDecl* IDecl,
|
2009-03-01 08:56:52 +08:00
|
|
|
bool IncompleteImpl = false);
|
2009-11-12 06:40:11 +08:00
|
|
|
|
|
|
|
/// AtomicPropertySetterGetterRules - This routine enforces the rule (via
|
|
|
|
/// warning) when atomic property has one but not the other user-declared
|
|
|
|
/// setter or getter.
|
|
|
|
void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
|
|
|
|
ObjCContainerDecl* IDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-10-06 02:00:57 +08:00
|
|
|
/// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
|
|
|
|
/// true, or false, accordingly.
|
2009-09-09 23:08:12 +08:00
|
|
|
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
|
2008-10-21 18:37:50 +08:00
|
|
|
const ObjCMethodDecl *PrevMethod,
|
2009-09-09 23:08:12 +08:00
|
|
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-09-30 22:38:43 +08:00
|
|
|
/// LookupInstanceMethodInGlobalPool - Returns the method and warns if
|
|
|
|
/// there are multiple signatures.
|
2009-08-23 05:13:55 +08:00
|
|
|
ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
|
|
|
|
bool warn=true);
|
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);
|
2009-09-09 23:08:12 +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);
|
2009-11-20 06:12:37 +08:00
|
|
|
virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
|
|
|
|
FullExprArg CondVal, StmtArg ThenVal,
|
2009-05-18 02:26:53 +08:00
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
|
2009-05-18 05:22:26 +08:00
|
|
|
FullExprArg Cond, StmtArg Body);
|
2009-01-17 07:28:06 +08:00
|
|
|
virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
|
2009-06-13 07:04:47 +08:00
|
|
|
SourceLocation WhileLoc,
|
|
|
|
SourceLocation CondLParen, ExprArg Cond,
|
|
|
|
SourceLocation CondRParen);
|
2009-01-17 07:28:06 +08:00
|
|
|
|
|
|
|
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,
|
2009-08-19 00:11:00 +08:00
|
|
|
ExprArg RetValExp);
|
2009-01-18 21:19:59 +08:00
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
ExprArg Throw,
|
2009-02-12 04:05:44 +08:00
|
|
|
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,
|
2009-08-19 09:27:57 +08:00
|
|
|
DeclaratorInfo *DInfo,
|
2009-05-19 04:51:54 +08:00
|
|
|
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
|
|
|
|
2009-07-31 06:17:18 +08:00
|
|
|
/// DiagnoseUnusedExprResult - If the statement passed in is an expression
|
|
|
|
/// whose result is unused, warn.
|
|
|
|
void DiagnoseUnusedExprResult(const Stmt *S);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-04 10:18:39 +08:00
|
|
|
ParsingDeclStackState PushParsingDeclaration();
|
|
|
|
void PopParsingDeclaration(ParsingDeclStackState S, DeclPtrTy D);
|
|
|
|
void EmitDeprecationWarning(NamedDecl *D, SourceLocation Loc);
|
|
|
|
|
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-11-04 10:18:39 +08:00
|
|
|
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
|
2009-09-09 23:08:12 +08:00
|
|
|
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
|
2009-05-09 04:20:55 +08:00
|
|
|
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
|
|
|
|
2009-11-05 17:23:39 +08:00
|
|
|
void CheckSignCompare(Expr *LHS, Expr *RHS, SourceLocation Loc,
|
2009-11-06 16:49:08 +08:00
|
|
|
const PartialDiagnostic &PD,
|
|
|
|
bool Equality = false);
|
2009-11-05 17:23:39 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual ExpressionEvaluationContext
|
2009-06-23 04:57:11 +08:00
|
|
|
PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
virtual void
|
2009-06-23 04:57:11 +08:00
|
|
|
PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
|
|
|
|
ExpressionEvaluationContext NewContext);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-20 07:52:42 +08:00
|
|
|
void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
|
2009-09-09 23:08:12 +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-11-04 00:56:39 +08:00
|
|
|
virtual OwningExprResult ActOnIdExpression(Scope *S,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
UnqualifiedId &Name,
|
|
|
|
bool HasTrailingLParen,
|
|
|
|
bool IsAddressOfOperand);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
OwningExprResult BuildDeclRefExpr(NamedDecl *D, QualType Ty,
|
|
|
|
SourceLocation Loc, bool TypeDependent,
|
2009-06-24 08:10:43 +08:00
|
|
|
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-11-22 09:44:31 +08:00
|
|
|
OwningExprResult BuildImplicitMemberReferenceExpr(const CXXScopeSpec *SS,
|
|
|
|
LookupResult &R);
|
|
|
|
bool UseArgumentDependentLookup(const CXXScopeSpec *SS,
|
|
|
|
const LookupResult &R,
|
|
|
|
bool HasTrailingLParen);
|
2009-11-21 16:51:07 +08:00
|
|
|
OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec *SS,
|
2009-11-22 09:44:31 +08:00
|
|
|
LookupResult &R, bool ADL);
|
2009-11-21 16:51:07 +08:00
|
|
|
OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec *SS,
|
|
|
|
SourceLocation Loc,
|
|
|
|
DeclarationName Name,
|
|
|
|
bool NeedsADL,
|
2009-11-22 08:44:51 +08:00
|
|
|
bool IsOverloaded,
|
2009-11-21 16:51:07 +08:00
|
|
|
NamedDecl * const *Decls,
|
|
|
|
unsigned NumDecls);
|
|
|
|
OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec *SS,
|
|
|
|
SourceLocation Loc,
|
|
|
|
NamedDecl *D);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-08-11 07:49:36 +08:00
|
|
|
virtual OwningExprResult ActOnParenListExpr(SourceLocation L,
|
|
|
|
SourceLocation R,
|
|
|
|
MultiExprArg Val);
|
2009-09-09 23:08:12 +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,
|
2009-09-09 23:08:12 +08:00
|
|
|
unsigned OpcIn,
|
2009-03-14 07:49:33 +08:00
|
|
|
ExprArg InputArg);
|
2009-11-05 08:51:44 +08:00
|
|
|
OwningExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
|
|
|
|
UnaryOperator::Opcode Opc, ExprArg input);
|
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-11-04 15:28:41 +08:00
|
|
|
OwningExprResult CreateSizeOfAlignOfExpr(DeclaratorInfo *T,
|
|
|
|
SourceLocation OpLoc,
|
2009-03-14 05:01:28 +08:00
|
|
|
bool isSizeOf, SourceRange R);
|
2009-09-09 23:08:12 +08:00
|
|
|
OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
|
2009-03-14 05:01:28 +08:00
|
|
|
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-09-09 23:08:12 +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);
|
2009-10-30 04:17:01 +08:00
|
|
|
OwningExprResult CreateBuiltinArraySubscriptExpr(ExprArg Base,
|
|
|
|
SourceLocation LLoc,
|
|
|
|
ExprArg Idx,
|
|
|
|
SourceLocation RLoc);
|
2009-09-01 08:37:14 +08:00
|
|
|
|
|
|
|
OwningExprResult BuildMemberReferenceExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
|
|
|
SourceLocation MemberLoc,
|
|
|
|
DeclarationName MemberName,
|
|
|
|
DeclPtrTy ImplDecl,
|
2009-09-04 05:38:09 +08:00
|
|
|
const CXXScopeSpec *SS = 0,
|
|
|
|
NamedDecl *FirstQualifierInScope = 0) {
|
2009-09-09 23:08:12 +08:00
|
|
|
// FIXME: Temporary helper while we migrate existing calls to
|
2009-09-01 08:37:14 +08:00
|
|
|
// BuildMemberReferenceExpr to support explicitly-specified template
|
|
|
|
// arguments.
|
|
|
|
return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, MemberLoc,
|
|
|
|
MemberName, false, SourceLocation(), 0, 0,
|
2009-09-04 05:38:09 +08:00
|
|
|
SourceLocation(), ImplDecl, SS,
|
|
|
|
FirstQualifierInScope);
|
2009-09-01 08:37:14 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-27 02:25:21 +08:00
|
|
|
OwningExprResult BuildMemberReferenceExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
|
|
|
SourceLocation MemberLoc,
|
|
|
|
DeclarationName MemberName,
|
2009-09-01 08:37:14 +08:00
|
|
|
bool HasExplicitTemplateArgs,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-09-01 08:37:14 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
SourceLocation RAngleLoc,
|
2009-08-27 02:25:21 +08:00
|
|
|
DeclPtrTy ImplDecl,
|
2009-09-04 05:38:09 +08:00
|
|
|
const CXXScopeSpec *SS,
|
|
|
|
NamedDecl *FirstQualifierInScope = 0);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-04 03:44:04 +08:00
|
|
|
virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
UnqualifiedId &Member,
|
|
|
|
DeclPtrTy ObjCImpDecl,
|
|
|
|
bool HasTrailingLParen);
|
|
|
|
|
2009-07-22 06:36:06 +08:00
|
|
|
virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl);
|
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
|
|
|
|
2009-09-22 23:41:20 +08:00
|
|
|
void DeconstructCallFunction(Expr *FnExpr,
|
2009-11-21 16:51:07 +08:00
|
|
|
llvm::SmallVectorImpl<NamedDecl*>& Fns,
|
2009-09-22 23:41:20 +08:00
|
|
|
DeclarationName &Name,
|
|
|
|
NestedNameSpecifier *&Qualifier,
|
|
|
|
SourceRange &QualifierRange,
|
|
|
|
bool &ArgumentDependentLookup,
|
2009-11-22 08:44:51 +08:00
|
|
|
bool &Overloaded,
|
2009-09-22 23:41:20 +08:00
|
|
|
bool &HasExplicitTemplateArguments,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *&ExplicitTemplateArgs,
|
2009-09-22 23:41:20 +08:00
|
|
|
unsigned &NumExplicitTemplateArgs);
|
|
|
|
|
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-08-11 07:49:36 +08:00
|
|
|
virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
|
|
|
|
TypeTy *Ty, SourceLocation RParenLoc,
|
|
|
|
ExprArg Op);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-11 07:49:36 +08:00
|
|
|
OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
|
|
|
|
OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc, ExprArg E,
|
|
|
|
QualType Ty);
|
2009-01-20 06:31:54 +08:00
|
|
|
|
|
|
|
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);
|
2009-11-05 08:51:44 +08:00
|
|
|
OwningExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
|
|
|
|
BinaryOperator::Opcode Opc,
|
|
|
|
Expr *lhs, Expr *rhs);
|
2009-01-20 06:31:54 +08:00
|
|
|
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-09-09 23:08:12 +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-06-20 08:51:54 +08:00
|
|
|
|
2009-11-17 13:59:44 +08:00
|
|
|
NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
|
|
|
|
SourceLocation UsingLoc,
|
2009-08-28 13:40:36 +08:00
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation IdentLoc,
|
|
|
|
DeclarationName Name,
|
|
|
|
AttributeList *AttrList,
|
2009-11-18 10:36:19 +08:00
|
|
|
bool IsInstantiation,
|
|
|
|
bool IsTypeName,
|
|
|
|
SourceLocation TypenameLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-20 08:51:54 +08:00
|
|
|
virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
|
2009-08-30 03:54:19 +08:00
|
|
|
AccessSpecifier AS,
|
2009-08-28 13:40:36 +08:00
|
|
|
SourceLocation UsingLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
2009-11-05 00:30:06 +08:00
|
|
|
UnqualifiedId &Name,
|
2009-08-28 13:40:36 +08:00
|
|
|
AttributeList *AttrList,
|
2009-11-18 10:36:19 +08:00
|
|
|
bool IsTypeName,
|
|
|
|
SourceLocation TypenameLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// AddCXXDirectInitializerToDecl - This action is called immediately after
|
2008-10-07 01:10:33 +08:00
|
|
|
/// 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-09-09 23:08:12 +08:00
|
|
|
bool InitializeVarWithConstructor(VarDecl *VD,
|
2009-04-17 07:50:50 +08:00
|
|
|
CXXConstructorDecl *Constructor,
|
2009-09-08 06:23:31 +08:00
|
|
|
MultiExprArg Exprs);
|
2009-08-16 13:13:48 +08:00
|
|
|
|
2009-09-05 15:40:38 +08:00
|
|
|
/// BuildCXXConstructExpr - Creates a complete call to a constructor,
|
|
|
|
/// including handling of its default argument expressions.
|
2009-09-09 23:08:12 +08:00
|
|
|
OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
|
2009-09-05 15:40:38 +08:00
|
|
|
QualType DeclInitType,
|
2009-08-25 13:12:04 +08:00
|
|
|
CXXConstructorDecl *Constructor,
|
2009-09-08 06:23:31 +08:00
|
|
|
MultiExprArg Exprs);
|
2009-08-16 13:13:48 +08:00
|
|
|
|
2009-09-05 15:40:38 +08:00
|
|
|
// FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
|
|
|
|
// the constructor can be elidable?
|
2009-09-09 23:08:12 +08:00
|
|
|
OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
|
2009-09-05 15:40:38 +08:00
|
|
|
QualType DeclInitType,
|
2009-08-25 13:12:04 +08:00
|
|
|
CXXConstructorDecl *Constructor,
|
|
|
|
bool Elidable,
|
2009-09-08 06:23:31 +08:00
|
|
|
MultiExprArg Exprs);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
OwningExprResult BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Cons,
|
|
|
|
QualType writtenTy,
|
|
|
|
SourceLocation tyBeginLoc,
|
2009-08-27 13:08:22 +08:00
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation rParenLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-10 05:33:21 +08:00
|
|
|
OwningExprResult BuildCXXCastArgument(SourceLocation CastLoc,
|
|
|
|
QualType Ty,
|
|
|
|
CastExpr::CastKind Kind,
|
|
|
|
CXXMethodDecl *Method,
|
|
|
|
ExprArg Arg);
|
|
|
|
|
2009-08-25 11:49:14 +08:00
|
|
|
/// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
|
|
|
|
/// the default expr if needed.
|
|
|
|
OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
|
|
|
|
FunctionDecl *FD,
|
|
|
|
ParmVarDecl *Param);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-04 03:13:25 +08:00
|
|
|
/// FinalizeVarWithDestructor - Prepare for calling destructor on the
|
|
|
|
/// constructed variable.
|
|
|
|
void FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// DefineImplicitDefaultConstructor - Checks for feasibility of
|
2009-06-20 03:55:27 +08:00
|
|
|
/// defining this constructor as the default constructor.
|
|
|
|
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
|
|
|
|
CXXConstructorDecl *Constructor);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// DefineImplicitDestructor - Checks for feasibility of
|
2009-06-27 07:49:16 +08:00
|
|
|
/// defining this destructor as the default destructor.
|
|
|
|
void DefineImplicitDestructor(SourceLocation CurrentLocation,
|
|
|
|
CXXDestructorDecl *Destructor);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// DefineImplicitCopyConstructor - Checks for feasibility of
|
2009-06-23 07:34:40 +08:00
|
|
|
/// defining this constructor as the copy constructor.
|
|
|
|
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
|
|
|
|
CXXConstructorDecl *Constructor,
|
|
|
|
unsigned TypeQuals);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-26 05:45:19 +08:00
|
|
|
/// DefineImplicitOverloadedAssign - Checks for feasibility of
|
|
|
|
/// defining implicit this overloaded assignment operator.
|
2009-09-09 23:08:12 +08:00
|
|
|
void DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
|
2009-06-26 05:45:19 +08:00
|
|
|
CXXMethodDecl *MethodDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-26 05:45:19 +08:00
|
|
|
/// getAssignOperatorMethod - Returns the default copy assignmment operator
|
|
|
|
/// for the class.
|
|
|
|
CXXMethodDecl *getAssignOperatorMethod(ParmVarDecl *Decl,
|
2009-09-09 23:08:12 +08:00
|
|
|
CXXRecordDecl *ClassDecl);
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2009-11-14 11:27:21 +08:00
|
|
|
CXXConstructorDecl *
|
|
|
|
TryInitializationByConstructor(QualType ClassType,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation Loc,
|
|
|
|
InitializationKind Kind);
|
|
|
|
|
2008-11-04 04:45:27 +08:00
|
|
|
CXXConstructorDecl *
|
2008-11-05 23:29:30 +08:00
|
|
|
PerformInitializationByConstructor(QualType ClassType,
|
2009-09-10 07:08:42 +08:00
|
|
|
MultiExprArg ArgsPtr,
|
2008-11-05 23:29:30 +08:00
|
|
|
SourceLocation Loc, SourceRange Range,
|
2008-11-24 13:29:24 +08:00
|
|
|
DeclarationName InitEntity,
|
2009-09-10 07:08:42 +08:00
|
|
|
InitializationKind Kind,
|
|
|
|
ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs);
|
|
|
|
|
|
|
|
bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
|
|
|
|
MultiExprArg ArgsPtr,
|
|
|
|
SourceLocation Loc,
|
|
|
|
ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs);
|
|
|
|
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
bool ParenTypeId,
|
2009-05-21 08:00:09 +08:00
|
|
|
QualType AllocType,
|
|
|
|
SourceLocation TypeLoc,
|
|
|
|
SourceRange TypeRange,
|
|
|
|
ExprArg ArraySize,
|
|
|
|
SourceLocation ConstructorLParen,
|
|
|
|
MultiExprArg ConstructorArgs,
|
|
|
|
SourceLocation ConstructorRParen);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-21 08:00:09 +08:00
|
|
|
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
|
|
|
|
2009-11-16 02:45:20 +08:00
|
|
|
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
|
|
|
|
DeclarationName Name, FunctionDecl* &Operator);
|
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
|
2009-09-03 06:59:36 +08:00
|
|
|
virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S,
|
|
|
|
ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
|
|
|
TypeTy *&ObjectType);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
|
2009-06-05 23:38:08 +08:00
|
|
|
/// non-empty, will create a new CXXExprWithTemporaries expression.
|
|
|
|
/// Otherwise, just returs the passed in expression.
|
2009-06-16 11:37:31 +08:00
|
|
|
Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr,
|
|
|
|
bool ShouldDestroyTemporaries);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-03 06:59:36 +08:00
|
|
|
DeclContext *computeDeclContext(QualType T);
|
2009-09-09 23:08:12 +08:00
|
|
|
DeclContext *computeDeclContext(const CXXScopeSpec &SS,
|
2009-07-22 07:53:31 +08:00
|
|
|
bool EnteringContext = false);
|
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);
|
|
|
|
|
2009-09-18 23:37:17 +08:00
|
|
|
bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
|
2009-09-04 05:38:09 +08:00
|
|
|
NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-04 05:38:09 +08:00
|
|
|
|
|
|
|
CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation IdLoc,
|
|
|
|
SourceLocation CCLoc,
|
|
|
|
IdentifierInfo &II,
|
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *ScopeLookupResult,
|
|
|
|
bool EnteringContext);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-09 01:17:31 +08:00
|
|
|
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation IdLoc,
|
|
|
|
SourceLocation CCLoc,
|
Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.
To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,
template<typename X> template<typename Y>
X Outer<X>::Inner1<Y>::foo(Y) {
return X();
}
we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.
Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.
llvm-svn: 80044
2009-08-26 06:51:20 +08:00
|
|
|
IdentifierInfo &II,
|
2009-09-03 06:59:36 +08:00
|
|
|
TypeTy *ObjectType,
|
Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.
To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,
template<typename X> template<typename Y>
X Outer<X>::Inner1<Y>::foo(Y) {
return X();
}
we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.
Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.
llvm-svn: 80044
2009-08-26 06:51:20 +08:00
|
|
|
bool EnteringContext);
|
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.
|
2009-09-25 07:39:01 +08:00
|
|
|
virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
|
2008-11-09 01:17:31 +08:00
|
|
|
|
|
|
|
/// 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
|
|
|
|
2009-06-18 06:50:06 +08:00
|
|
|
/// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
|
|
|
|
/// initializer for the declaration 'Dcl'.
|
|
|
|
/// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
|
|
|
|
/// static data member of class X, names should be looked up in the scope of
|
|
|
|
/// class X.
|
|
|
|
virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl);
|
|
|
|
|
|
|
|
/// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
|
|
|
|
/// initializer for the declaration 'Dcl'.
|
|
|
|
virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl);
|
|
|
|
|
2007-08-22 01:43:55 +08:00
|
|
|
// ParseObjCStringLiteral - Parse Objective-C string literals.
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
2007-12-12 09:04:12 +08:00
|
|
|
ExprTy **Strings,
|
|
|
|
unsigned NumStrings);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
|
2009-06-08 02:45:35 +08:00
|
|
|
QualType EncodedType,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation RParenLoc);
|
2009-09-29 07:23:40 +08:00
|
|
|
CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp, CXXMethodDecl *Method);
|
|
|
|
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-09-09 23:08:12 +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,
|
2009-08-21 06:52:58 +08:00
|
|
|
MultiTemplateParamsArg TemplateParameterLists,
|
2009-03-29 03:18:32 +08:00
|
|
|
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,
|
2009-07-01 07:26:25 +08:00
|
|
|
const CXXScopeSpec &SS,
|
2008-11-05 12:29:56 +08:00
|
|
|
IdentifierInfo *MemberOrBase,
|
2009-07-02 03:21:19 +08:00
|
|
|
TypeTy *TemplateTypeTy,
|
2008-11-05 12:29:56 +08:00
|
|
|
SourceLocation IdLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
ExprTy **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2009-07-30 03:44:27 +08:00
|
|
|
MemInitResult BuildMemberInitializer(FieldDecl *Member, Expr **Args,
|
|
|
|
unsigned NumArgs, SourceLocation IdLoc,
|
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
|
|
|
MemInitResult BuildBaseInitializer(QualType BaseType, Expr **Args,
|
|
|
|
unsigned NumArgs, SourceLocation IdLoc,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
CXXRecordDecl *ClassDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-10 04:14:44 +08:00
|
|
|
bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
|
2009-09-04 03:36:46 +08:00
|
|
|
CXXBaseOrMemberInitializer **Initializers,
|
|
|
|
unsigned NumInitializers,
|
2009-11-09 09:05:47 +08:00
|
|
|
bool IsImplicitConstructor);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-17 12:44:12 +08:00
|
|
|
/// MarkBaseAndMemberDestructorsReferenced - Given a destructor decl,
|
|
|
|
/// mark all its non-trivial member and base destructor declarations
|
|
|
|
/// as referenced.
|
|
|
|
void MarkBaseAndMemberDestructorsReferenced(CXXDestructorDecl *Destructor);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-04 01:51:48 +08:00
|
|
|
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
|
2009-03-25 10:58:17 +08:00
|
|
|
SourceLocation ColonLoc,
|
|
|
|
MemInitTy **MemInits, unsigned NumMemInits);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
ExprArg AssertExpr,
|
|
|
|
ExprArg AssertMessageExpr);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-17 06:47:08 +08:00
|
|
|
DeclPtrTy ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
|
|
|
|
MultiTemplateParamsArg TemplateParams);
|
2009-09-12 05:02:39 +08:00
|
|
|
DeclPtrTy ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition,
|
|
|
|
MultiTemplateParamsArg TemplateParams);
|
2009-05-12 06:55:49 +08:00
|
|
|
|
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-11-16 06:49:34 +08:00
|
|
|
void CheckDestructor(CXXDestructorDecl *Destructor);
|
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
|
|
|
|
2009-10-22 15:08:30 +08:00
|
|
|
bool isImplicitMemberReference(const CXXScopeSpec *SS, NamedDecl *D,
|
|
|
|
SourceLocation NameLoc, QualType &ThisType,
|
|
|
|
QualType &MemberType);
|
|
|
|
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType BaseType,
|
2009-03-03 12:44:36 +08:00
|
|
|
SourceLocation BaseLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
|
2008-10-23 08:40:37 +08:00
|
|
|
SourceRange SpecifierRange,
|
|
|
|
bool Virtual, AccessSpecifier Access,
|
2009-09-09 23:08:12 +08:00
|
|
|
TypeTy *basetype, SourceLocation
|
2009-03-03 12:44:36 +08:00
|
|
|
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-09-09 23:08:12 +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);
|
2009-10-07 01:59:45 +08:00
|
|
|
bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths);
|
|
|
|
|
2008-10-25 00:17:19 +08:00
|
|
|
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
|
2009-11-15 05:15:49 +08:00
|
|
|
SourceLocation Loc, SourceRange Range,
|
|
|
|
bool IgnoreAccess = false);
|
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-09-09 23:08:12 +08:00
|
|
|
|
2009-10-07 01:59:45 +08:00
|
|
|
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-07-08 04:29:57 +08:00
|
|
|
/// CheckOverridingFunctionReturnType - Checks whether the return types are
|
|
|
|
/// covariant, according to C++ [class.virtual]p5.
|
|
|
|
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
|
2009-05-14 09:09:04 +08:00
|
|
|
const CXXMethodDecl *Old);
|
2009-07-08 04:29:57 +08:00
|
|
|
|
|
|
|
/// CheckOverridingFunctionExceptionSpec - Checks whether the exception
|
|
|
|
/// spec is a subset of base spec.
|
|
|
|
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
|
|
|
|
const CXXMethodDecl *Old);
|
2008-04-14 05:30:24 +08:00
|
|
|
|
2009-11-21 16:43:09 +08:00
|
|
|
/// CheckOverridingFunctionAttributes - Checks whether attributes are
|
|
|
|
/// incompatible or prevent overriding.
|
|
|
|
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
|
|
|
|
const CXXMethodDecl *Old);
|
|
|
|
|
2009-03-27 13:05:05 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Access Control
|
|
|
|
//
|
2009-07-18 22:32:15 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
|
2009-03-27 13:05:05 +08:00
|
|
|
NamedDecl *PrevMemberDecl,
|
|
|
|
AccessSpecifier LexicalAS);
|
2009-07-18 22:32:15 +08:00
|
|
|
|
|
|
|
const CXXBaseSpecifier *FindInaccessibleBase(QualType Derived, QualType Base,
|
2009-10-07 01:59:45 +08:00
|
|
|
CXXBasePaths &Paths,
|
2009-07-18 22:32:15 +08:00
|
|
|
bool NoPrivileges = false);
|
|
|
|
|
|
|
|
bool CheckBaseClassAccess(QualType Derived, QualType Base,
|
2009-05-14 05:11:42 +08:00
|
|
|
unsigned InaccessibleBaseID,
|
2009-10-07 01:59:45 +08:00
|
|
|
CXXBasePaths& Paths, SourceLocation AccessLoc,
|
2009-05-14 05:11:42 +08:00
|
|
|
DeclarationName Name);
|
2009-07-18 22:32:15 +08:00
|
|
|
|
|
|
|
|
2009-03-24 09:19:16 +08:00
|
|
|
enum AbstractDiagSelID {
|
|
|
|
AbstractNone = -1,
|
|
|
|
AbstractReturnType,
|
|
|
|
AbstractParamType,
|
|
|
|
AbstractVariableType,
|
|
|
|
AbstractFieldType
|
|
|
|
};
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-27 08:13:57 +08:00
|
|
|
bool RequireNonAbstractType(SourceLocation Loc, QualType T,
|
|
|
|
const PartialDiagnostic &PD,
|
|
|
|
const CXXRecordDecl *CurrentRD = 0);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
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-09-03 06:59:36 +08:00
|
|
|
virtual TemplateNameKind isTemplateName(Scope *S,
|
2009-11-04 07:16:33 +08:00
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
UnqualifiedId &Name,
|
2009-09-03 06:59:36 +08:00
|
|
|
TypeTy *ObjectType,
|
Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.
To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,
template<typename X> template<typename Y>
X Outer<X>::Inner1<Y>::foo(Y) {
return X();
}
we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.
Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.
llvm-svn: 80044
2009-08-26 06:51:20 +08:00
|
|
|
bool EnteringContext,
|
|
|
|
TemplateTy &Template);
|
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);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
|
2009-06-13 03:58:00 +08:00
|
|
|
SourceLocation EllipsisLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
SourceLocation KeyLoc,
|
|
|
|
IdentifierInfo *ParamName,
|
|
|
|
SourceLocation ParamNameLoc,
|
|
|
|
unsigned Depth, unsigned Position);
|
2009-09-09 23:08:12 +08:00
|
|
|
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,
|
2009-11-11 09:00:40 +08:00
|
|
|
const ParsedTemplateArgument &Default);
|
2009-02-11 03:49:53 +08:00
|
|
|
|
2008-12-24 10:52:09 +08:00
|
|
|
virtual TemplateParamsTy *
|
|
|
|
ActOnTemplateParameterList(unsigned Depth,
|
|
|
|
SourceLocation ExportLoc,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation TemplateLoc,
|
2008-12-24 10:52:09 +08:00
|
|
|
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-07-22 07:53:31 +08:00
|
|
|
TemplateParameterList *
|
|
|
|
MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
TemplateParameterList **ParamLists,
|
2009-10-08 06:35:40 +08:00
|
|
|
unsigned NumParamLists,
|
|
|
|
bool &IsExplicitSpecialization);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-07-31 10:45:11 +08:00
|
|
|
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
2009-07-24 00:36:45 +08:00
|
|
|
SourceLocation KWLoc, const CXXScopeSpec &SS,
|
|
|
|
IdentifierInfo *Name, SourceLocation NameLoc,
|
|
|
|
AttributeList *Attr,
|
2009-08-26 01:23:04 +08:00
|
|
|
TemplateParameterList *TemplateParams,
|
2009-07-24 00:36:45 +08:00
|
|
|
AccessSpecifier AS);
|
2009-02-07 06:42:48 +08:00
|
|
|
|
2009-09-26 07:53:26 +08:00
|
|
|
void translateTemplateArguments(ASTTemplateArgsPtr &TemplateArgsIn,
|
2009-11-11 03:49:08 +08:00
|
|
|
llvm::SmallVectorImpl<TemplateArgumentLoc> &TempArgs);
|
2009-09-26 07:53:26 +08:00
|
|
|
|
2009-03-31 06:58:21 +08:00
|
|
|
QualType CheckTemplateIdType(TemplateName Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *TemplateArgs,
|
2009-03-31 06:58:21 +08:00
|
|
|
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,
|
2009-09-09 01:47:29 +08:00
|
|
|
SourceLocation RAngleLoc);
|
|
|
|
|
|
|
|
virtual TypeResult ActOnTagTemplateIdType(TypeResult Type,
|
|
|
|
TagUseKind TUK,
|
|
|
|
DeclSpec::TST TagSpec,
|
|
|
|
SourceLocation TagLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-10-23 01:20:55 +08:00
|
|
|
OwningExprResult BuildTemplateIdExpr(NestedNameSpecifier *Qualifier,
|
|
|
|
SourceRange QualifierRange,
|
|
|
|
TemplateName Template,
|
2009-07-01 06:34:41 +08:00
|
|
|
SourceLocation TemplateNameLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *TemplateArgs,
|
2009-07-01 06:34:41 +08:00
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceLocation RAngleLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-04 00:56:39 +08:00
|
|
|
OwningExprResult ActOnTemplateIdExpr(const CXXScopeSpec &SS,
|
|
|
|
TemplateTy Template,
|
|
|
|
SourceLocation TemplateNameLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
|
|
|
ASTTemplateArgsPtr TemplateArgs,
|
|
|
|
SourceLocation RAngleLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-31 08:43:58 +08:00
|
|
|
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
|
2009-09-03 06:59:36 +08:00
|
|
|
const CXXScopeSpec &SS,
|
2009-11-04 07:16:33 +08:00
|
|
|
UnqualifiedId &Name,
|
2009-11-21 07:39:24 +08:00
|
|
|
TypeTy *ObjectType,
|
|
|
|
bool EnteringContext);
|
2009-03-31 08:43:58 +08:00
|
|
|
|
2009-06-13 05:21:02 +08:00
|
|
|
bool CheckClassTemplatePartialSpecializationArgs(
|
|
|
|
TemplateParameterList *TemplateParams,
|
2009-06-14 02:20:51 +08:00
|
|
|
const TemplateArgumentListBuilder &TemplateArgs,
|
2009-06-13 06:08:06 +08:00
|
|
|
bool &MirrorsPrimaryTemplate);
|
2009-02-26 06:02:03 +08:00
|
|
|
|
2009-03-25 08:13:59 +08:00
|
|
|
virtual DeclResult
|
2009-07-31 10:45:11 +08:00
|
|
|
ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation KWLoc,
|
2009-02-18 07:15:12 +08:00
|
|
|
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 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-09-09 23:08:12 +08:00
|
|
|
virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
|
2009-06-24 07:11:28 +08:00
|
|
|
MultiTemplateParamsArg TemplateParameterLists,
|
|
|
|
Declarator &D);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
|
2009-06-24 08:54:41 +08:00
|
|
|
MultiTemplateParamsArg TemplateParameterLists,
|
|
|
|
Declarator &D);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-10-28 02:42:08 +08:00
|
|
|
bool
|
|
|
|
CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
|
|
|
|
TemplateSpecializationKind NewTSK,
|
|
|
|
NamedDecl *PrevDecl,
|
|
|
|
TemplateSpecializationKind PrevTSK,
|
|
|
|
SourceLocation PrevPointOfInstantiation,
|
|
|
|
bool &SuppressNew);
|
|
|
|
|
2009-09-25 07:14:47 +08:00
|
|
|
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
|
|
|
|
bool HasExplicitTemplateArgs,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-09-25 07:14:47 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
SourceLocation RAngleLoc,
|
2009-11-19 06:49:29 +08:00
|
|
|
LookupResult &Previous);
|
|
|
|
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
|
2009-09-25 07:14:47 +08:00
|
|
|
|
2009-05-13 08:25:59 +08:00
|
|
|
virtual DeclResult
|
2009-09-09 23:08:12 +08:00
|
|
|
ActOnExplicitInstantiation(Scope *S,
|
2009-09-04 14:33:52 +08:00
|
|
|
SourceLocation ExternLoc,
|
|
|
|
SourceLocation TemplateLoc,
|
2009-09-09 23:08:12 +08:00
|
|
|
unsigned TagSpec,
|
2009-05-13 08:25:59 +08:00
|
|
|
SourceLocation KWLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
TemplateTy Template,
|
|
|
|
SourceLocation TemplateNameLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
|
|
|
ASTTemplateArgsPtr TemplateArgs,
|
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
AttributeList *Attr);
|
|
|
|
|
2009-05-14 08:28:11 +08:00
|
|
|
virtual DeclResult
|
2009-09-09 23:08:12 +08:00
|
|
|
ActOnExplicitInstantiation(Scope *S,
|
2009-09-04 14:33:52 +08:00
|
|
|
SourceLocation ExternLoc,
|
|
|
|
SourceLocation TemplateLoc,
|
2009-09-09 23:08:12 +08:00
|
|
|
unsigned TagSpec,
|
2009-05-14 08:28:11 +08:00
|
|
|
SourceLocation KWLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
AttributeList *Attr);
|
|
|
|
|
2009-09-26 02:43:00 +08:00
|
|
|
virtual DeclResult ActOnExplicitInstantiation(Scope *S,
|
|
|
|
SourceLocation ExternLoc,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
Declarator &D);
|
|
|
|
|
2009-11-12 03:31:23 +08:00
|
|
|
bool CheckTemplateArgument(NamedDecl *Param,
|
|
|
|
const TemplateArgumentLoc &Arg,
|
|
|
|
TemplateDecl *Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
TemplateArgumentListBuilder &Converted);
|
|
|
|
|
2009-02-10 07:23:08 +08:00
|
|
|
bool CheckTemplateArgumentList(TemplateDecl *Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation LAngleLoc,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *TemplateArgs,
|
2009-03-10 07:48:35 +08:00
|
|
|
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,
|
2009-07-01 08:28:38 +08:00
|
|
|
bool PartialTemplateArgs,
|
2009-06-05 11:43:12 +08:00
|
|
|
TemplateArgumentListBuilder &Converted);
|
2009-06-13 08:33:33 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc &Arg,
|
2009-06-13 08:33:33 +08:00
|
|
|
TemplateArgumentListBuilder &Converted);
|
2009-02-10 07:23:08 +08:00
|
|
|
|
2009-10-29 16:12:44 +08:00
|
|
|
bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
|
|
|
|
DeclaratorInfo *Arg);
|
2009-09-09 23:08:12 +08:00
|
|
|
bool CheckTemplateArgumentAddressOfObjectOrFunction(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
|
|
|
NamedDecl *&Entity);
|
2009-11-13 02:38:13 +08:00
|
|
|
bool CheckTemplateArgumentPointerToMember(Expr *Arg,
|
|
|
|
TemplateArgument &Converted);
|
2009-09-09 23:08:12 +08:00
|
|
|
bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
|
2009-03-03 12:44:36 +08:00
|
|
|
QualType InstantiatedParamType, Expr *&Arg,
|
2009-06-12 02:10:32 +08:00
|
|
|
TemplateArgument &Converted);
|
2009-11-11 09:00:40 +08:00
|
|
|
bool CheckTemplateArgument(TemplateTemplateParmDecl *Param,
|
|
|
|
const TemplateArgumentLoc &Arg);
|
2009-11-13 00:20:59 +08:00
|
|
|
|
|
|
|
/// \brief Enumeration describing how template parameter lists are compared
|
|
|
|
/// for equality.
|
|
|
|
enum TemplateParameterListEqualKind {
|
|
|
|
/// \brief We are matching the template parameter lists of two templates
|
|
|
|
/// that might be redeclarations.
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// template<typename T> struct X;
|
|
|
|
/// template<typename T> struct X;
|
|
|
|
/// \endcode
|
|
|
|
TPL_TemplateMatch,
|
|
|
|
|
|
|
|
/// \brief We are matching the template parameter lists of two template
|
|
|
|
/// template parameters as part of matching the template parameter lists
|
|
|
|
/// of two templates that might be redeclarations.
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// template<template<int I> class TT> struct X;
|
|
|
|
/// template<template<int Value> class Other> struct X;
|
|
|
|
/// \endcode
|
|
|
|
TPL_TemplateTemplateParmMatch,
|
|
|
|
|
|
|
|
/// \brief We are matching the template parameter lists of a template
|
|
|
|
/// template argument against the template parameter lists of a template
|
|
|
|
/// template parameter.
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// template<template<int Value> class Metafun> struct X;
|
|
|
|
/// template<int Value> struct integer_c;
|
|
|
|
/// X<integer_c> xic;
|
|
|
|
/// \endcode
|
|
|
|
TPL_TemplateTemplateArgumentMatch
|
|
|
|
};
|
|
|
|
|
2009-02-07 06:42:48 +08:00
|
|
|
bool TemplateParameterListsAreEqual(TemplateParameterList *New,
|
|
|
|
TemplateParameterList *Old,
|
|
|
|
bool Complain,
|
2009-11-13 00:20:59 +08:00
|
|
|
TemplateParameterListEqualKind Kind,
|
2009-02-10 08:24:35 +08:00
|
|
|
SourceLocation TemplateArgLoc
|
2009-11-11 09:00:40 +08:00
|
|
|
= SourceLocation());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-26 01:23:04 +08:00
|
|
|
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
|
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
|
2009-09-09 23:08:12 +08:00
|
|
|
/// specifier that ends in a template-id, e.g.,
|
2009-04-01 08:28:59 +08:00
|
|
|
/// "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-05-31 17:31:02 +08:00
|
|
|
|
2009-08-07 00:20:37 +08:00
|
|
|
QualType RebuildTypeInCurrentInstantiation(QualType T, SourceLocation Loc,
|
|
|
|
DeclarationName Name);
|
|
|
|
|
2009-09-16 00:23:51 +08:00
|
|
|
std::string
|
|
|
|
getTemplateArgumentBindingsText(const TemplateParameterList *Params,
|
|
|
|
const TemplateArgumentList &Args);
|
2009-11-12 03:13:48 +08:00
|
|
|
|
|
|
|
std::string
|
|
|
|
getTemplateArgumentBindingsText(const TemplateParameterList *Params,
|
|
|
|
const TemplateArgument *Args,
|
|
|
|
unsigned NumArgs);
|
2009-09-16 00:23:51 +08:00
|
|
|
|
2009-06-13 02:26:56 +08:00
|
|
|
/// \brief Describes the result of template argument deduction.
|
|
|
|
///
|
|
|
|
/// The TemplateDeductionResult enumeration describes the result of
|
|
|
|
/// template argument deduction, as returned from
|
|
|
|
/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
|
|
|
|
/// structure provides additional information about the results of
|
|
|
|
/// template argument deduction, e.g., the deduced template argument
|
|
|
|
/// list (if successful) or the specific template parameters or
|
|
|
|
/// deduced arguments that were involved in the failure.
|
|
|
|
enum TemplateDeductionResult {
|
|
|
|
/// \brief Template argument deduction was successful.
|
|
|
|
TDK_Success = 0,
|
|
|
|
/// \brief Template argument deduction exceeded the maximum template
|
|
|
|
/// instantiation depth (which has already been diagnosed).
|
|
|
|
TDK_InstantiationDepth,
|
|
|
|
/// \brief Template argument deduction did not deduce a value
|
|
|
|
/// for every template parameter.
|
|
|
|
TDK_Incomplete,
|
|
|
|
/// \brief Template argument deduction produced inconsistent
|
|
|
|
/// deduced values for the given template parameter.
|
|
|
|
TDK_Inconsistent,
|
|
|
|
/// \brief Template argument deduction failed due to inconsistent
|
|
|
|
/// cv-qualifiers on a template parameter type that would
|
|
|
|
/// otherwise be deduced, e.g., we tried to deduce T in "const T"
|
|
|
|
/// but were given a non-const "X".
|
|
|
|
TDK_InconsistentQuals,
|
|
|
|
/// \brief Substitution of the deduced template argument values
|
|
|
|
/// resulted in an error.
|
|
|
|
TDK_SubstitutionFailure,
|
|
|
|
/// \brief Substitution of the deduced template argument values
|
|
|
|
/// into a non-deduced context produced a type or value that
|
|
|
|
/// produces a type that does not match the original template
|
|
|
|
/// arguments provided.
|
2009-06-26 06:08:12 +08:00
|
|
|
TDK_NonDeducedMismatch,
|
2009-09-09 23:08:12 +08:00
|
|
|
/// \brief When performing template argument deduction for a function
|
2009-06-26 06:08:12 +08:00
|
|
|
/// template, there were too many call arguments.
|
|
|
|
TDK_TooManyArguments,
|
2009-09-09 23:08:12 +08:00
|
|
|
/// \brief When performing template argument deduction for a function
|
2009-06-26 06:08:12 +08:00
|
|
|
/// template, there were too few call arguments.
|
2009-07-01 07:57:56 +08:00
|
|
|
TDK_TooFewArguments,
|
|
|
|
/// \brief The explicitly-specified template arguments were not valid
|
|
|
|
/// template arguments for the given template.
|
|
|
|
TDK_InvalidExplicitArguments
|
2009-06-13 02:26:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Provides information about an attempted template argument
|
|
|
|
/// deduction, whose success or failure was described by a
|
|
|
|
/// TemplateDeductionResult value.
|
|
|
|
class TemplateDeductionInfo {
|
|
|
|
/// \brief The context in which the template arguments are stored.
|
|
|
|
ASTContext &Context;
|
|
|
|
|
|
|
|
/// \brief The deduced template argument list.
|
|
|
|
///
|
|
|
|
TemplateArgumentList *Deduced;
|
|
|
|
|
|
|
|
// do not implement these
|
|
|
|
TemplateDeductionInfo(const TemplateDeductionInfo&);
|
|
|
|
TemplateDeductionInfo &operator=(const TemplateDeductionInfo&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
TemplateDeductionInfo(ASTContext &Context) : Context(Context), Deduced(0) { }
|
|
|
|
|
|
|
|
~TemplateDeductionInfo() {
|
|
|
|
// FIXME: if (Deduced) Deduced->Destroy(Context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Take ownership of the deduced template argument list.
|
2009-09-09 23:08:12 +08:00
|
|
|
TemplateArgumentList *take() {
|
2009-06-13 02:26:56 +08:00
|
|
|
TemplateArgumentList *Result = Deduced;
|
|
|
|
Deduced = 0;
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Provide a new template argument list that contains the
|
|
|
|
/// results of template argument deduction.
|
|
|
|
void reset(TemplateArgumentList *NewDeduced) {
|
|
|
|
// FIXME: if (Deduced) Deduced->Destroy(Context);
|
|
|
|
Deduced = NewDeduced;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief The template parameter to which a template argument
|
|
|
|
/// deduction failure refers.
|
|
|
|
///
|
|
|
|
/// Depending on the result of template argument deduction, this
|
|
|
|
/// template parameter may have different meanings:
|
|
|
|
///
|
|
|
|
/// TDK_Incomplete: this is the first template parameter whose
|
|
|
|
/// corresponding template argument was not deduced.
|
|
|
|
///
|
|
|
|
/// TDK_Inconsistent: this is the template parameter for which
|
|
|
|
/// two different template argument values were deduced.
|
|
|
|
TemplateParameter Param;
|
|
|
|
|
|
|
|
/// \brief The first template argument to which the template
|
|
|
|
/// argument deduction failure refers.
|
|
|
|
///
|
|
|
|
/// Depending on the result of the template argument deduction,
|
|
|
|
/// this template argument may have different meanings:
|
|
|
|
///
|
|
|
|
/// TDK_Inconsistent: this argument is the first value deduced
|
|
|
|
/// for the corresponding template parameter.
|
|
|
|
///
|
|
|
|
/// TDK_SubstitutionFailure: this argument is the template
|
|
|
|
/// argument we were instantiating when we encountered an error.
|
|
|
|
///
|
|
|
|
/// TDK_NonDeducedMismatch: this is the template argument
|
|
|
|
/// provided in the source code.
|
|
|
|
TemplateArgument FirstArg;
|
|
|
|
|
|
|
|
/// \brief The second template argument to which the template
|
|
|
|
/// argument deduction failure refers.
|
|
|
|
///
|
|
|
|
/// FIXME: Finish documenting this.
|
|
|
|
TemplateArgument SecondArg;
|
|
|
|
};
|
|
|
|
|
|
|
|
TemplateDeductionResult
|
2009-06-05 08:53:49 +08:00
|
|
|
DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
|
2009-06-13 02:26:56 +08:00
|
|
|
const TemplateArgumentList &TemplateArgs,
|
|
|
|
TemplateDeductionInfo &Info);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-07-09 04:55:45 +08:00
|
|
|
TemplateDeductionResult
|
|
|
|
SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-07-09 04:55:45 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
llvm::SmallVectorImpl<TemplateArgument> &Deduced,
|
|
|
|
llvm::SmallVectorImpl<QualType> &ParamTypes,
|
|
|
|
QualType *FunctionType,
|
|
|
|
TemplateDeductionInfo &Info);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
TemplateDeductionResult
|
2009-07-09 04:55:45 +08:00
|
|
|
FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
llvm::SmallVectorImpl<TemplateArgument> &Deduced,
|
|
|
|
FunctionDecl *&Specialization,
|
|
|
|
TemplateDeductionInfo &Info);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-26 06:08:12 +08:00
|
|
|
TemplateDeductionResult
|
|
|
|
DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
|
2009-07-01 07:57:56 +08:00
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-07-01 07:57:56 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
2009-06-26 06:08:12 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
FunctionDecl *&Specialization,
|
|
|
|
TemplateDeductionInfo &Info);
|
2009-07-09 04:55:45 +08:00
|
|
|
|
|
|
|
TemplateDeductionResult
|
|
|
|
DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
bool HasExplicitTemplateArgs,
|
2009-10-29 16:12:44 +08:00
|
|
|
const TemplateArgumentLoc *ExplicitTemplateArgs,
|
2009-07-09 04:55:45 +08:00
|
|
|
unsigned NumExplicitTemplateArgs,
|
|
|
|
QualType ArgFunctionType,
|
|
|
|
FunctionDecl *&Specialization,
|
|
|
|
TemplateDeductionInfo &Info);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-22 07:19:43 +08:00
|
|
|
TemplateDeductionResult
|
|
|
|
DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
QualType ToType,
|
|
|
|
CXXConversionDecl *&Specialization,
|
|
|
|
TemplateDeductionInfo &Info);
|
|
|
|
|
|
|
|
FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
|
|
|
|
FunctionTemplateDecl *FT2,
|
2009-09-15 02:39:43 +08:00
|
|
|
TemplatePartialOrderingContext TPOC);
|
2009-09-26 02:43:00 +08:00
|
|
|
FunctionDecl *getMostSpecialized(FunctionDecl **Specializations,
|
|
|
|
unsigned NumSpecializations,
|
|
|
|
TemplatePartialOrderingContext TPOC,
|
|
|
|
SourceLocation Loc,
|
|
|
|
const PartialDiagnostic &NoneDiag,
|
|
|
|
const PartialDiagnostic &AmbigDiag,
|
|
|
|
const PartialDiagnostic &CandidateDiag,
|
|
|
|
unsigned *Index = 0);
|
|
|
|
|
2009-09-16 00:23:51 +08:00
|
|
|
ClassTemplatePartialSpecializationDecl *
|
|
|
|
getMoreSpecializedPartialSpecialization(
|
|
|
|
ClassTemplatePartialSpecializationDecl *PS1,
|
|
|
|
ClassTemplatePartialSpecializationDecl *PS2);
|
|
|
|
|
2009-09-15 05:25:05 +08:00
|
|
|
void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
|
|
|
|
bool OnlyDeduced,
|
2009-10-29 08:04:11 +08:00
|
|
|
unsigned Depth,
|
2009-09-19 07:21:38 +08:00
|
|
|
llvm::SmallVectorImpl<bool> &Used);
|
|
|
|
void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
llvm::SmallVectorImpl<bool> &Deduced);
|
|
|
|
|
2009-02-28 03:31:52 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Template Instantiation
|
|
|
|
//
|
2009-03-10 08:06:19 +08:00
|
|
|
|
2009-11-10 03:17:50 +08:00
|
|
|
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D,
|
|
|
|
const TemplateArgumentList *Innermost = 0);
|
2009-05-15 07:26:13 +08:00
|
|
|
|
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
|
2009-07-02 06:01:06 +08:00
|
|
|
enum InstantiationKind {
|
2009-03-11 04:44:00 +08:00
|
|
|
/// 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.
|
2009-06-11 07:47:09 +08:00
|
|
|
/// FIXME: Use a TemplateArgumentList
|
|
|
|
DefaultTemplateArgumentInstantiation,
|
|
|
|
|
2009-09-05 13:14:19 +08:00
|
|
|
/// We are instantiating a default argument for a function.
|
|
|
|
/// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
|
|
|
|
/// provides the template arguments as specified.
|
|
|
|
DefaultFunctionArgumentInstantiation,
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// We are substituting explicit template arguments provided for
|
2009-07-02 06:01:06 +08:00
|
|
|
/// a function template. The entity is a FunctionTemplateDecl.
|
|
|
|
ExplicitTemplateArgumentSubstitution,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-07-02 06:01:06 +08:00
|
|
|
/// We are substituting template argument determined as part of
|
|
|
|
/// template argument deduction for either a class template
|
|
|
|
/// partial specialization or a function template. The
|
|
|
|
/// Entity is either a ClassTemplatePartialSpecializationDecl or
|
|
|
|
/// a FunctionTemplateDecl.
|
2009-11-12 03:13:48 +08:00
|
|
|
DeducedTemplateArgumentSubstitution,
|
|
|
|
|
|
|
|
/// We are substituting prior template arguments into a new
|
|
|
|
/// template parameter. The template parameter itself is either a
|
|
|
|
/// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
|
2009-11-12 05:54:23 +08:00
|
|
|
PriorTemplateArgumentSubstitution,
|
|
|
|
|
|
|
|
/// We are checking the validity of a default template argument that
|
|
|
|
/// has been used when naming a template-id.
|
|
|
|
DefaultTemplateArgumentChecking
|
2009-03-11 04:44:00 +08:00
|
|
|
} Kind;
|
|
|
|
|
2009-03-10 08:06:19 +08:00
|
|
|
/// \brief The point of instantiation within the source code.
|
|
|
|
SourceLocation PointOfInstantiation;
|
|
|
|
|
2009-11-12 03:13:48 +08:00
|
|
|
/// \brief The template in which we are performing the instantiation,
|
|
|
|
/// for substitutions of prior template arguments.
|
|
|
|
TemplateDecl *Template;
|
|
|
|
|
2009-03-10 08:06:19 +08:00
|
|
|
/// \brief The entity that is being instantiated.
|
2009-03-11 04:44:00 +08:00
|
|
|
uintptr_t Entity;
|
|
|
|
|
2009-11-12 03:13:48 +08:00
|
|
|
/// \brief The list of template arguments we are substituting, if they
|
|
|
|
/// are not part of the entity.
|
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
|
|
|
|
2009-11-12 03:13:48 +08:00
|
|
|
ActiveTemplateInstantiation()
|
|
|
|
: Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0),
|
|
|
|
NumTemplateArgs(0) {}
|
2009-08-16 06:50:33 +08:00
|
|
|
|
2009-11-12 05:54:23 +08:00
|
|
|
/// \brief Determines whether this template is an actual instantiation
|
|
|
|
/// that should be counted toward the maximum instantiation depth.
|
|
|
|
bool isInstantiationRecord() const;
|
|
|
|
|
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;
|
|
|
|
|
2009-11-12 03:13:48 +08:00
|
|
|
case PriorTemplateArgumentSubstitution:
|
2009-11-12 05:54:23 +08:00
|
|
|
case DefaultTemplateArgumentChecking:
|
2009-11-12 03:13:48 +08:00
|
|
|
if (X.Template != Y.Template)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Fall through
|
|
|
|
|
2009-03-11 04:44:00 +08:00
|
|
|
case DefaultTemplateArgumentInstantiation:
|
2009-07-02 06:01:06 +08:00
|
|
|
case ExplicitTemplateArgumentSubstitution:
|
|
|
|
case DeducedTemplateArgumentSubstitution:
|
2009-09-05 13:14:19 +08:00
|
|
|
case DefaultFunctionArgumentInstantiation:
|
2009-03-11 04:44:00 +08:00
|
|
|
return X.TemplateArgs == Y.TemplateArgs;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-11 04:44:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2009-09-09 23:08:12 +08:00
|
|
|
llvm::SmallVector<ActiveTemplateInstantiation, 16>
|
2009-03-10 08:06:19 +08:00
|
|
|
ActiveTemplateInstantiations;
|
|
|
|
|
2009-11-12 05:54:23 +08:00
|
|
|
/// \brief The number of ActiveTemplateInstantiation entries in
|
|
|
|
/// \c ActiveTemplateInstantiations that are not actual instantiations and,
|
|
|
|
/// therefore, should not be counted as part of the instantiation depth.
|
|
|
|
unsigned NonInstantiationEntries;
|
|
|
|
|
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,
|
2009-06-11 07:47:09 +08:00
|
|
|
SourceRange InstantiationRange = SourceRange());
|
|
|
|
|
2009-07-02 06:01:06 +08:00
|
|
|
/// \brief Note that we are instantiating a default argument in a
|
|
|
|
/// template-id.
|
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
ActiveTemplateInstantiation::InstantiationKind Kind,
|
|
|
|
SourceRange InstantiationRange = SourceRange());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-11 07:47:09 +08:00
|
|
|
/// \brief Note that we are instantiating as part of template
|
|
|
|
/// argument deduction for a class template partial
|
|
|
|
/// specialization.
|
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
ClassTemplatePartialSpecializationDecl *PartialSpec,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
2009-03-11 04:44:00 +08:00
|
|
|
SourceRange InstantiationRange = SourceRange());
|
|
|
|
|
2009-09-05 13:14:19 +08:00
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
ParmVarDecl *Param,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceRange InstantiationRange = SourceRange());
|
|
|
|
|
2009-11-12 03:13:48 +08:00
|
|
|
/// \brief Note that we are substituting prior template arguments into a
|
|
|
|
/// non-type or template template parameter.
|
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
TemplateDecl *Template,
|
|
|
|
NonTypeTemplateParmDecl *Param,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceRange InstantiationRange);
|
|
|
|
|
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
TemplateDecl *Template,
|
|
|
|
TemplateTemplateParmDecl *Param,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceRange InstantiationRange);
|
|
|
|
|
2009-11-12 05:54:23 +08:00
|
|
|
/// \brief Note that we are checking the default template argument
|
|
|
|
/// against the template parameter for a given template-id.
|
|
|
|
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
|
|
|
|
TemplateDecl *Template,
|
|
|
|
NamedDecl *Param,
|
|
|
|
const TemplateArgument *TemplateArgs,
|
|
|
|
unsigned NumTemplateArgs,
|
|
|
|
SourceRange InstantiationRange);
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
InstantiatingTemplate&
|
2009-03-10 08:06:19 +08:00
|
|
|
operator=(const InstantiatingTemplate&); // not implemented
|
|
|
|
};
|
|
|
|
|
2009-03-11 02:03:33 +08:00
|
|
|
void PrintInstantiationStack();
|
|
|
|
|
2009-06-14 15:33:30 +08:00
|
|
|
/// \brief Determines whether we are currently in a context where
|
|
|
|
/// template argument substitution failures are not considered
|
|
|
|
/// errors.
|
|
|
|
///
|
|
|
|
/// When this routine returns true, the emission of most diagnostics
|
|
|
|
/// will be suppressed and there will be no local error recovery.
|
|
|
|
bool isSFINAEContext() const;
|
|
|
|
|
2009-06-14 16:02:22 +08:00
|
|
|
/// \brief RAII class used to determine whether SFINAE has
|
|
|
|
/// trapped any errors that occur during template argument
|
|
|
|
/// deduction.
|
|
|
|
class SFINAETrap {
|
|
|
|
Sema &SemaRef;
|
|
|
|
unsigned PrevSFINAEErrors;
|
|
|
|
public:
|
|
|
|
explicit SFINAETrap(Sema &SemaRef)
|
|
|
|
: SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors) { }
|
|
|
|
|
|
|
|
~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; }
|
|
|
|
|
|
|
|
/// \brief Determine whether any SFINAE errors have been trapped.
|
2009-09-09 23:08:12 +08:00
|
|
|
bool hasErrorOccurred() const {
|
|
|
|
return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
|
2009-06-14 16:02:22 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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
|
2009-11-01 01:21:17 +08:00
|
|
|
/// definitions from some other instantiation (that may not be
|
2009-05-15 05:44:34 +08:00
|
|
|
/// relevant to this particular scope).
|
|
|
|
LocalInstantiationScope *Outer;
|
|
|
|
|
|
|
|
// This class is non-copyable
|
|
|
|
LocalInstantiationScope(const LocalInstantiationScope &);
|
|
|
|
LocalInstantiationScope &operator=(const LocalInstantiationScope &);
|
|
|
|
|
|
|
|
public:
|
2009-11-01 01:21:17 +08:00
|
|
|
LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false)
|
2009-09-09 23:08:12 +08:00
|
|
|
: SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) {
|
2009-11-01 01:21:17 +08:00
|
|
|
if (!CombineWithOuterScope)
|
|
|
|
SemaRef.CurrentInstantiationScope = this;
|
|
|
|
else
|
|
|
|
assert(SemaRef.CurrentInstantiationScope &&
|
|
|
|
"No outer instantiation scope?");
|
2009-05-15 05:44:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~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-11-01 01:21:17 +08:00
|
|
|
NonTypeTemplateParmDecl *getInstantiationOf(
|
|
|
|
const NonTypeTemplateParmDecl *Var) {
|
|
|
|
return cast<NonTypeTemplateParmDecl>(getInstantiationOf(cast<Decl>(Var)));
|
|
|
|
}
|
|
|
|
|
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-06-23 07:06:13 +08:00
|
|
|
/// \brief An entity for which implicit template instantiation is required.
|
|
|
|
///
|
2009-09-09 23:08:12 +08:00
|
|
|
/// The source location associated with the declaration is the first place in
|
2009-06-23 07:06:13 +08:00
|
|
|
/// the source code where the declaration was "used". It is not necessarily
|
2009-09-09 23:08:12 +08:00
|
|
|
/// the point of instantiation (which will be either before or after the
|
2009-06-23 07:06:13 +08:00
|
|
|
/// namespace-scope declaration that triggered this implicit instantiation),
|
|
|
|
/// However, it is the location that diagnostics should generally refer to,
|
|
|
|
/// because users will need to know what code triggered the instantiation.
|
|
|
|
typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-23 07:06:13 +08:00
|
|
|
/// \brief The queue of implicit template instantiations that are required
|
|
|
|
/// but have not yet been performed.
|
2009-07-01 01:20:14 +08:00
|
|
|
std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations;
|
2009-06-23 07:06:13 +08:00
|
|
|
|
|
|
|
void PerformPendingImplicitInstantiations();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-10-21 08:58:09 +08:00
|
|
|
DeclaratorInfo *SubstType(DeclaratorInfo *T,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs,
|
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType SubstType(QualType T,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs,
|
2009-08-26 06:02:44 +08:00
|
|
|
SourceLocation Loc, DeclarationName Entity);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
OwningExprResult SubstExpr(Expr *E,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-03-13 00:53:44 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
OwningStmtResult SubstStmt(Stmt *S,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-05-15 07:26:13 +08:00
|
|
|
|
2009-08-26 06:02:44 +08:00
|
|
|
Decl *SubstDecl(Decl *D, DeclContext *Owner,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-03-18 05:15:40 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
bool
|
2009-08-26 06:02:44 +08:00
|
|
|
SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
|
|
|
|
CXXRecordDecl *Pattern,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-08-20 09:44:21 +08:00
|
|
|
|
2009-03-26 05:17:03 +08:00
|
|
|
bool
|
|
|
|
InstantiateClass(SourceLocation PointOfInstantiation,
|
|
|
|
CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs,
|
2009-09-05 06:48:11 +08:00
|
|
|
TemplateSpecializationKind TSK,
|
2009-08-24 23:23:48 +08:00
|
|
|
bool Complain = true);
|
2009-03-26 05:17:03 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
bool
|
2009-10-27 14:26:26 +08:00
|
|
|
InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
|
2009-03-03 12:44:36 +08:00
|
|
|
ClassTemplateSpecializationDecl *ClassTemplateSpec,
|
2009-09-05 06:48:11 +08:00
|
|
|
TemplateSpecializationKind TSK,
|
|
|
|
bool Complain = true);
|
2009-02-28 03:31:52 +08:00
|
|
|
|
2009-05-14 04:28:22 +08:00
|
|
|
void InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
|
|
|
CXXRecordDecl *Instantiation,
|
2009-09-05 06:48:11 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs,
|
|
|
|
TemplateSpecializationKind TSK);
|
2009-05-14 04:28:22 +08:00
|
|
|
|
|
|
|
void InstantiateClassTemplateSpecializationMembers(
|
|
|
|
SourceLocation PointOfInstantiation,
|
2009-09-05 06:48:11 +08:00
|
|
|
ClassTemplateSpecializationDecl *ClassTemplateSpec,
|
|
|
|
TemplateSpecializationKind TSK);
|
2009-05-14 04:28:22 +08:00
|
|
|
|
2009-03-27 07:50:42 +08:00
|
|
|
NestedNameSpecifier *
|
2009-08-26 06:02:44 +08:00
|
|
|
SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
|
|
|
|
SourceRange Range,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &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
|
2009-08-26 06:02:44 +08:00
|
|
|
SubstTemplateName(TemplateName Name, SourceLocation Loc,
|
2009-08-29 04:31:08 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-10-29 16:12:44 +08:00
|
|
|
bool Subst(const TemplateArgumentLoc &Arg, TemplateArgumentLoc &Result,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-04-01 02:38:02 +08:00
|
|
|
|
2009-05-19 01:01:57 +08:00
|
|
|
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
|
2009-07-01 01:20:14 +08:00
|
|
|
FunctionDecl *Function,
|
2009-10-15 22:05:49 +08:00
|
|
|
bool Recursive = false,
|
|
|
|
bool DefinitionRequired = false);
|
2009-07-25 04:34:43 +08:00
|
|
|
void InstantiateStaticDataMemberDefinition(
|
2009-08-26 06:02:44 +08:00
|
|
|
SourceLocation PointOfInstantiation,
|
|
|
|
VarDecl *Var,
|
2009-10-15 22:05:49 +08:00
|
|
|
bool Recursive = false,
|
|
|
|
bool DefinitionRequired = false);
|
2009-05-14 04:28:22 +08:00
|
|
|
|
2009-08-29 13:16:22 +08:00
|
|
|
void InstantiateMemInitializers(CXXConstructorDecl *New,
|
|
|
|
const CXXConstructorDecl *Tmpl,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-17 02:34:49 +08:00
|
|
|
NamedDecl *FindInstantiatedDecl(NamedDecl *D,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
|
|
|
DeclContext *FindInstantiatedContext(DeclContext *DC,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +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,
|
2009-09-09 23:08:12 +08:00
|
|
|
IdentifierInfo *SuperClassname,
|
2007-09-26 02:38:09 +08:00
|
|
|
SourceLocation SuperClassLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnStartCategoryImplementation(
|
2007-10-03 00:38:50 +08:00
|
|
|
SourceLocation AtCatImplLoc,
|
2009-09-09 23:08:12 +08:00
|
|
|
IdentifierInfo *ClassName,
|
2007-10-03 00:38:50 +08:00
|
|
|
SourceLocation ClassLoc,
|
|
|
|
IdentifierInfo *CatName,
|
|
|
|
SourceLocation CatLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
|
2009-11-18 07:12:20 +08:00
|
|
|
IdentifierInfo **IdentList,
|
|
|
|
SourceLocation *IdentLocs,
|
|
|
|
unsigned NumElts);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// Ensure attributes are consistent with type.
|
2008-09-24 05:53:23 +08:00
|
|
|
/// \param [in, out] Attributes The attributes to check; they will
|
|
|
|
/// be modified to be consistent with \arg PropertyTy.
|
2009-09-09 23:08:12 +08:00
|
|
|
void CheckObjCPropertyAttributes(QualType PropertyTy,
|
2008-09-24 05:53:23 +08:00
|
|
|
SourceLocation Loc,
|
|
|
|
unsigned &Attributes);
|
2009-01-09 01:28:14 +08:00
|
|
|
void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
|
2009-09-09 23:08:12 +08:00
|
|
|
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
|
2008-05-01 08:03:38 +08:00
|
|
|
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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
|
2009-08-04 09:07:16 +08:00
|
|
|
ObjCMethodDecl *MethodDecl,
|
|
|
|
bool IsInstance);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-12-07 07:03:39 +08:00
|
|
|
void MergeProtocolPropertiesIntoClass(Decl *CDecl,
|
2009-03-29 03:18:32 +08:00
|
|
|
DeclPtrTy MergeProtocols);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
|
2009-03-03 03:05:07 +08:00
|
|
|
ObjCInterfaceDecl *ID);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-12-07 07:03:39 +08:00
|
|
|
void MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
|
2008-05-03 03:17:30 +08:00
|
|
|
ObjCProtocolDecl *PDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc,
|
2009-03-29 03:18:32 +08:00
|
|
|
SourceLocation PropertyLoc,
|
|
|
|
bool ImplKind,DeclPtrTy ClassImplDecl,
|
|
|
|
IdentifierInfo *PropertyId,
|
|
|
|
IdentifierInfo *PropertyIvar);
|
2009-09-09 23:08:12 +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 {.
|
2009-09-09 23:08:12 +08:00
|
|
|
tok::TokenKind MethodType,
|
|
|
|
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-09-09 23:08:12 +08:00
|
|
|
ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
|
2009-03-09 02:56:13 +08:00
|
|
|
ObjCInterfaceDecl *CDecl);
|
|
|
|
ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
|
|
|
|
ObjCInterfaceDecl *ClassDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-10 05:12:44 +08:00
|
|
|
virtual OwningExprResult ActOnClassPropertyRefExpr(
|
|
|
|
IdentifierInfo &receiverName,
|
|
|
|
IdentifierInfo &propertyName,
|
|
|
|
SourceLocation &receiverNameLoc,
|
|
|
|
SourceLocation &propertyNameLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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-09-09 23:08:12 +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-09-09 23:08:12 +08:00
|
|
|
SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac,
|
2007-11-15 21:05:42 +08:00
|
|
|
ExprTy **ArgExprs, unsigned NumArgs);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-10-14 13:35:18 +08:00
|
|
|
/// ActOnPragmaPack - Called on well formed #pragma pack(...).
|
|
|
|
virtual void ActOnPragmaPack(PragmaPackKind Kind,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
ExprTy *Alignment,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation PragmaLoc,
|
2008-10-14 13:35:18 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-24 06:28:25 +08:00
|
|
|
/// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
|
2009-08-04 07:24:57 +08:00
|
|
|
virtual void ActOnPragmaUnused(const Token *Identifiers,
|
|
|
|
unsigned NumIdentifiers, Scope *curScope,
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation PragmaLoc,
|
2009-03-24 06:28:25 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc);
|
2009-06-05 10:44:36 +08:00
|
|
|
|
2009-07-31 10:52:19 +08:00
|
|
|
NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II);
|
|
|
|
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
|
2009-07-30 11:15:39 +08:00
|
|
|
|
2009-06-05 14:28:29 +08:00
|
|
|
/// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
|
2009-06-05 10:44:36 +08:00
|
|
|
virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName,
|
|
|
|
SourceLocation PragmaLoc,
|
|
|
|
SourceLocation WeakNameLoc);
|
|
|
|
|
2009-06-05 14:28:29 +08:00
|
|
|
/// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
|
2009-06-05 10:44:36 +08:00
|
|
|
virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
|
|
|
|
IdentifierInfo* AliasName,
|
|
|
|
SourceLocation PragmaLoc,
|
|
|
|
SourceLocation WeakNameLoc,
|
|
|
|
SourceLocation AliasNameLoc);
|
|
|
|
|
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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-02-17 09:09:29 +08:00
|
|
|
/// 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.
|
2009-10-20 16:27:19 +08:00
|
|
|
void ImpCastExprToType(Expr *&Expr, QualType Type, CastExpr::CastKind Kind,
|
2009-07-31 09:23:52 +08:00
|
|
|
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).
|
2009-09-09 23:08:12 +08:00
|
|
|
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
|
2009-09-09 23:08:12 +08:00
|
|
|
// to their respective pointers (C99 6.3.2.1).
|
2007-07-17 05:54:35 +08:00
|
|
|
void DefaultFunctionArrayConversion(Expr *&expr);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-29 07:30:39 +08:00
|
|
|
// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
|
2009-09-09 23:08:12 +08:00
|
|
|
// do not have a prototype. Integer promotions are performed on each
|
2007-08-29 07:30:39 +08:00
|
|
|
// 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,
|
2009-09-08 09:48:42 +08:00
|
|
|
VariadicMethod,
|
|
|
|
VariadicConstructor
|
2009-01-17 00:48:51 +08:00
|
|
|
};
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-01-17 00:48:51 +08:00
|
|
|
// 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);
|
2009-09-09 23:08:12 +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
|
2009-09-09 23:08:12 +08:00
|
|
|
// routine returns the first non-arithmetic type found. The client is
|
2007-06-05 06:22:31 +08:00
|
|
|
// responsible for emitting appropriate error diagnostics.
|
2007-08-25 03:07:16 +08:00
|
|
|
QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
|
|
|
|
bool isCompAssign = false);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-01-05 02:22:42 +08:00
|
|
|
/// PointerToInt - The assignment converts a pointer to an int, which we
|
|
|
|
/// accept as an extension.
|
|
|
|
PointerToInt,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-01-05 02:22:42 +08:00
|
|
|
/// IntToPointer - The assignment converts an int to a pointer, which we
|
|
|
|
/// accept as an extension.
|
|
|
|
IntToPointer,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-01-05 02:22:42 +08:00
|
|
|
/// 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,
|
2009-11-08 04:20:40 +08:00
|
|
|
|
2009-11-08 15:46:34 +08:00
|
|
|
/// IncompatibleNestedPointerQualifiers - The assignment is between two
|
|
|
|
/// nested pointer types, and the qualifiers other than the first two
|
2009-11-10 06:28:08 +08:00
|
|
|
/// levels differ e.g. char ** -> const char **, but we accept them as an
|
|
|
|
/// extension.
|
2009-11-08 15:46:34 +08:00
|
|
|
IncompatibleNestedPointerQualifiers,
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// IntToBlockPointer - The assignment converts an int to a block
|
2008-09-04 23:10:53 +08:00
|
|
|
/// pointer. We disallow this.
|
|
|
|
IntToBlockPointer,
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// IncompatibleBlockPointer - The assignment is between two block
|
2008-09-04 23:10:53 +08:00
|
|
|
/// pointers types that are not compatible.
|
|
|
|
IncompatibleBlockPointer,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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
|
|
|
};
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// CheckAssignmentConstraints - Perform type checking for assignment,
|
|
|
|
/// argument passing, variable initialization, and function return values.
|
2008-01-05 02:04:52 +08:00
|
|
|
/// This routine is only used by the following two methods. C99 6.5.16.
|
|
|
|
AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
// CheckSingleAssignmentConstraints - Currently used by
|
|
|
|
// CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
|
2007-07-14 07:32:42 +08:00
|
|
|
// this routine performs the default function/array converions.
|
2009-09-09 23:08:12 +08:00
|
|
|
AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
|
2008-01-05 02:04:52 +08:00
|
|
|
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.
|
2009-09-09 23:08:12 +08:00
|
|
|
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
|
2009-04-30 06:16:16 +08:00
|
|
|
Expr *&rExpr);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-06-07 02:38:38 +08:00
|
|
|
// Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
|
2009-09-09 23:08:12 +08:00
|
|
|
AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
|
2008-01-05 02:04:52 +08:00
|
|
|
QualType rhsType);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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.
|
2009-09-09 23:08:12 +08:00
|
|
|
AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
|
2008-09-04 23:10:53 +08:00
|
|
|
QualType rhsType);
|
2008-09-12 08:47:35 +08:00
|
|
|
|
|
|
|
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
|
2008-10-24 12:54:22 +08:00
|
|
|
|
2009-10-10 20:04:10 +08:00
|
|
|
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
|
|
|
|
|
2009-09-09 23:08:12 +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-09-24 04:55:32 +08:00
|
|
|
bool PerformImplicitConversion(Expr *&From, QualType ToType,
|
|
|
|
const char *Flavor,
|
|
|
|
bool AllowExplicit,
|
|
|
|
bool Elidable,
|
|
|
|
ImplicitConversionSequence& ICS);
|
2009-09-09 23:08:12 +08:00
|
|
|
bool PerformImplicitConversion(Expr *&From, QualType ToType,
|
2009-01-14 23:45:31 +08:00
|
|
|
const ImplicitConversionSequence& ICS,
|
2009-11-15 05:15:49 +08:00
|
|
|
const char *Flavor,
|
|
|
|
bool IgnoreBaseAccess = false);
|
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,
|
2009-11-15 05:15:49 +08:00
|
|
|
const char *Flavor, bool IgnoreBaseAccess);
|
2009-10-17 03:20:59 +08:00
|
|
|
|
|
|
|
bool BuildCXXDerivedToBaseExpr(Expr *&From, CastExpr::CastKind CastKind,
|
|
|
|
const ImplicitConversionSequence& ICS,
|
|
|
|
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);
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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,
|
2009-09-09 23:08:12 +08:00
|
|
|
const IdentifierInfo *Comp,
|
2009-08-27 02:25:21 +08:00
|
|
|
SourceLocation CmpLoc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-09-02 10:04:30 +08:00
|
|
|
/// type checking declaration initializers (C99 6.7.8)
|
2009-09-09 23:08:12 +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);
|
2009-09-09 23:08:12 +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
|
|
|
|
};
|
|
|
|
|
2009-11-05 21:06:35 +08:00
|
|
|
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
|
|
|
|
QualType T1, QualType T2,
|
2008-10-29 10:00:59 +08:00
|
|
|
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,
|
2009-09-24 07:04:10 +08:00
|
|
|
SourceLocation DeclLoc,
|
2009-08-28 01:30:43 +08:00
|
|
|
bool SuppressUserConversions,
|
|
|
|
bool AllowExplicit,
|
|
|
|
bool ForceRValue,
|
2009-11-15 05:15:49 +08:00
|
|
|
ImplicitConversionSequence *ICS = 0,
|
|
|
|
bool IgnoreBaseAccess = false);
|
2008-10-29 08:13:59 +08:00
|
|
|
|
2009-07-25 23:41:38 +08:00
|
|
|
/// CheckCastTypes - Check type constraints for casting between types under
|
2009-07-29 21:50:23 +08:00
|
|
|
/// C semantics, or forward to CXXCheckCStyleCast in C++.
|
|
|
|
bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr,
|
2009-09-09 23:08:12 +08:00
|
|
|
CastExpr::CastKind &Kind,
|
2009-08-27 02:55:36 +08:00
|
|
|
CXXMethodDecl *& ConversionDecl,
|
|
|
|
bool FunctionalStyle = false);
|
2009-07-25 23:41:38 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
// CheckVectorCast - check type constraints for vectors.
|
2007-11-27 15:16:40 +08:00
|
|
|
// 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
|
2009-10-16 10:48:28 +08:00
|
|
|
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
|
|
|
|
CastExpr::CastKind &Kind);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
// CheckExtVectorCast - check type constraints for extended vectors.
|
2009-06-26 08:50:28 +08:00
|
|
|
// 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,
|
|
|
|
// or vectors and the element type of that vector.
|
|
|
|
// returns true if the cast is invalid
|
2009-10-16 13:23:41 +08:00
|
|
|
bool CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *&CastExpr,
|
|
|
|
CastExpr::CastKind &Kind);
|
2009-07-25 23:41:38 +08:00
|
|
|
|
|
|
|
/// CXXCheckCStyleCast - Check constraints of a C-style or function-style
|
|
|
|
/// cast under C++ semantics.
|
2009-07-29 21:50:23 +08:00
|
|
|
bool CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
|
2009-08-27 02:55:36 +08:00
|
|
|
CastExpr::CastKind &Kind, bool FunctionalStyle,
|
|
|
|
CXXMethodDecl *&ConversionDecl);
|
2009-07-25 23:41:38 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// CheckMessageArgumentTypes - Check types in an Obj-C message send.
|
2008-09-11 08:01:56 +08:00
|
|
|
/// \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,
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType &ReturnType);
|
2008-09-10 10:17:11 +08:00
|
|
|
|
2009-10-13 05:59:07 +08:00
|
|
|
/// CheckBooleanCondition - Diagnose problems involving the use of
|
|
|
|
/// the given expression as a boolean condition (e.g. in an if
|
|
|
|
/// statement). Also performs the standard function and array
|
|
|
|
/// decays, possibly changing the input variable.
|
|
|
|
///
|
|
|
|
/// \param Loc - A location associated with the condition, e.g. the
|
|
|
|
/// 'if' keyword.
|
|
|
|
/// \return true iff there were any errors
|
|
|
|
bool CheckBooleanCondition(Expr *&CondExpr, SourceLocation Loc);
|
|
|
|
|
|
|
|
/// DiagnoseAssignmentAsCondition - Given that an expression is
|
|
|
|
/// being used as a boolean condition, warn if it's an assignment.
|
|
|
|
void DiagnoseAssignmentAsCondition(Expr *E);
|
|
|
|
|
2008-09-10 10:17:11 +08:00
|
|
|
/// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
|
|
|
|
bool CheckCXXBooleanCondition(Expr *&CondExpr);
|
2009-07-25 23:41:38 +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.
|
2009-09-09 23:08:12 +08:00
|
|
|
void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
|
2007-08-23 13:46:52 +08:00
|
|
|
unsigned NewWidth, bool NewSign,
|
|
|
|
SourceLocation Loc, unsigned DiagID);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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
|
2009-09-09 23:08:12 +08:00
|
|
|
/// the correct width, and that the field type is valid.
|
2008-12-07 04:33:04 +08:00
|
|
|
/// Returns false on success.
|
2009-08-16 05:55:26 +08:00
|
|
|
/// Can optionally return whether the bit-field is of width 0
|
2009-09-09 23:08:12 +08:00
|
|
|
bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
|
|
|
|
QualType FieldTy, const Expr *BitWidth,
|
2009-08-16 05:55:26 +08:00
|
|
|
bool *ZeroWidth = 0);
|
2009-01-19 08:08:26 +08:00
|
|
|
|
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
/// \name Code completion
|
|
|
|
//@{
|
2009-09-22 04:51:25 +08:00
|
|
|
virtual void CodeCompleteOrdinaryName(Scope *S);
|
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
virtual void CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
bool IsArrow);
|
2009-09-18 23:37:17 +08:00
|
|
|
virtual void CodeCompleteTag(Scope *S, unsigned TagSpec);
|
2009-09-22 02:10:23 +08:00
|
|
|
virtual void CodeCompleteCase(Scope *S);
|
2009-09-22 23:41:20 +08:00
|
|
|
virtual void CodeCompleteCall(Scope *S, ExprTy *Fn,
|
|
|
|
ExprTy **Args, unsigned NumArgs);
|
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
virtual void CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS,
|
|
|
|
bool EnteringContext);
|
2009-09-19 03:03:04 +08:00
|
|
|
virtual void CodeCompleteUsing(Scope *S);
|
|
|
|
virtual void CodeCompleteUsingDirective(Scope *S);
|
|
|
|
virtual void CodeCompleteNamespaceDecl(Scope *S);
|
|
|
|
virtual void CodeCompleteNamespaceAliasDecl(Scope *S);
|
2009-09-19 04:05:18 +08:00
|
|
|
virtual void CodeCompleteOperatorName(Scope *S);
|
2009-10-09 05:55:05 +08:00
|
|
|
|
2009-11-19 07:08:07 +08:00
|
|
|
virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
|
2009-11-19 15:41:15 +08:00
|
|
|
virtual void CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl,
|
|
|
|
DeclPtrTy *Methods,
|
|
|
|
unsigned NumMethods);
|
|
|
|
virtual void CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ClassDecl,
|
|
|
|
DeclPtrTy *Methods,
|
|
|
|
unsigned NumMethods);
|
|
|
|
|
2009-11-18 07:31:36 +08:00
|
|
|
virtual void CodeCompleteObjCClassMessage(Scope *S, IdentifierInfo *FName,
|
2009-11-19 09:08:35 +08:00
|
|
|
SourceLocation FNameLoc,
|
|
|
|
IdentifierInfo **SelIdents,
|
|
|
|
unsigned NumSelIdents);
|
|
|
|
virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
|
|
|
|
IdentifierInfo **SelIdents,
|
|
|
|
unsigned NumSelIdents);
|
2009-11-18 12:19:12 +08:00
|
|
|
virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
|
|
|
unsigned NumProtocols);
|
2009-11-18 12:49:41 +08:00
|
|
|
virtual void CodeCompleteObjCProtocolDecl(Scope *S);
|
2009-11-19 00:26:39 +08:00
|
|
|
virtual void CodeCompleteObjCInterfaceDecl(Scope *S);
|
|
|
|
virtual void CodeCompleteObjCSuperclass(Scope *S,
|
|
|
|
IdentifierInfo *ClassName);
|
|
|
|
virtual void CodeCompleteObjCImplementationDecl(Scope *S);
|
2009-11-19 03:08:43 +08:00
|
|
|
virtual void CodeCompleteObjCInterfaceCategory(Scope *S,
|
|
|
|
IdentifierInfo *ClassName);
|
|
|
|
virtual void CodeCompleteObjCImplementationCategory(Scope *S,
|
|
|
|
IdentifierInfo *ClassName);
|
2009-11-19 06:56:13 +08:00
|
|
|
virtual void CodeCompleteObjCPropertyDefinition(Scope *S,
|
2009-11-19 06:32:06 +08:00
|
|
|
DeclPtrTy ObjCImpDecl);
|
|
|
|
virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
|
|
|
|
IdentifierInfo *PropertyName,
|
|
|
|
DeclPtrTy ObjCImpDecl);
|
2009-11-19 00:26:39 +08:00
|
|
|
//@}
|
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
llvm-svn: 82166
2009-09-18 05:32:03 +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-08-16 09:56:34 +08:00
|
|
|
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
|
|
|
|
bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-02-19 01:49:48 +08:00
|
|
|
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
|
|
|
|
unsigned ByteNo) const;
|
2009-08-06 11:00:50 +08:00
|
|
|
bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall);
|
2009-02-18 14:01:06 +08:00
|
|
|
bool CheckObjCString(Expr *Arg);
|
2009-08-16 09:56:34 +08:00
|
|
|
|
|
|
|
Action::OwningExprResult CheckBuiltinFunctionCall(unsigned BuiltinID,
|
|
|
|
CallExpr *TheCall);
|
2007-12-28 13:29:59 +08:00
|
|
|
bool SemaBuiltinVAStart(CallExpr *TheCall);
|
|
|
|
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
|
2009-09-01 04:06:00 +08:00
|
|
|
bool SemaBuiltinUnaryFP(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:
|
2009-09-09 23:08:12 +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-09-23 14:06:36 +08:00
|
|
|
bool SemaBuiltinEHReturnDataRegNo(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-09-09 23:08:12 +08:00
|
|
|
void CheckNonNullArguments(const NonNullAttr *NonNull,
|
2009-05-22 02:48:51 +08:00
|
|
|
const CallExpr *TheCall);
|
2009-09-09 23:08:12 +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-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-09-09 23:08:12 +08:00
|
|
|
|
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(); }
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-02-07 09:47:29 +08:00
|
|
|
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
|