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"
|
2010-03-23 08:13:23 +08:00
|
|
|
#include "AnalysisBasedWarnings.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"
|
2009-12-16 10:09:40 +08:00
|
|
|
#include "clang/AST/FullExpr.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-12-07 16:24:59 +08:00
|
|
|
#include <map>
|
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;
|
2009-12-16 20:17:52 +08:00
|
|
|
class UnresolvedLookupExpr;
|
2010-01-27 09:50:18 +08:00
|
|
|
class UnresolvedMemberExpr;
|
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;
|
2010-02-25 09:56:36 +08:00
|
|
|
class PseudoDestructorTypeStorage;
|
2009-07-04 19:39:00 +08:00
|
|
|
class FunctionProtoType;
|
2010-02-10 17:31:12 +08:00
|
|
|
class CXXBasePath;
|
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;
|
2009-12-10 07:02:17 +08:00
|
|
|
class InitializedEntity;
|
|
|
|
class InitializationKind;
|
|
|
|
class InitializationSequence;
|
2009-12-31 01:04:44 +08:00
|
|
|
class VisibleDeclConsumer;
|
2010-01-10 20:58:08 +08:00
|
|
|
class TargetAttributesSema;
|
2010-01-26 15:16:45 +08:00
|
|
|
class ADLResult;
|
2009-12-31 01:04:44 +08:00
|
|
|
|
2010-03-02 04:44:28 +08:00
|
|
|
/// \brief Retains information about a function, method, or block that is
|
|
|
|
/// currently being parsed.
|
|
|
|
struct FunctionScopeInfo {
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
/// \brief Whether this scope information structure defined information for
|
|
|
|
/// a block.
|
|
|
|
bool IsBlockInfo;
|
|
|
|
|
|
|
|
/// \brief Set true when a function, method contains a VLA or 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 NeedsScopeChecking;
|
|
|
|
|
|
|
|
/// \brief The number of errors that had occurred before starting this
|
|
|
|
/// function or block.
|
|
|
|
unsigned NumErrorsAtStartOfFunction;
|
|
|
|
|
2010-03-02 04:44:28 +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;
|
|
|
|
|
|
|
|
/// SwitchStack - This is the current set of active switch statements in the
|
|
|
|
/// block.
|
|
|
|
llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
|
|
|
|
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
FunctionScopeInfo(unsigned NumErrors)
|
|
|
|
: IsBlockInfo(false), NeedsScopeChecking(false),
|
|
|
|
NumErrorsAtStartOfFunction(NumErrors) { }
|
|
|
|
|
|
|
|
virtual ~FunctionScopeInfo();
|
|
|
|
|
|
|
|
/// \brief Clear out the information in this function scope, making it
|
|
|
|
/// suitable for reuse.
|
|
|
|
void Clear(unsigned NumErrors);
|
2010-03-02 04:44:28 +08:00
|
|
|
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
static bool classof(const FunctionScopeInfo *FSI) { return true; }
|
2010-03-02 04:44:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// \brief Retains information about a block that is currently being parsed.
|
|
|
|
struct BlockScopeInfo : FunctionScopeInfo {
|
2009-04-19 04:01:55 +08:00
|
|
|
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
|
|
|
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
BlockScopeInfo(unsigned NumErrors, Scope *BlockScope, BlockDecl *Block)
|
|
|
|
: FunctionScopeInfo(NumErrors), hasPrototype(false), isVariadic(false),
|
|
|
|
hasBlockDeclRefExprs(false), TheDecl(Block), TheScope(BlockScope)
|
|
|
|
{
|
|
|
|
IsBlockInfo = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~BlockScopeInfo();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-03-02 04:44:28 +08:00
|
|
|
static bool classof(const FunctionScopeInfo *FSI) { return FSI->IsBlockInfo; }
|
|
|
|
static bool classof(const BlockScopeInfo *BSI) { return true; }
|
2009-04-19 04:01:55 +08:00
|
|
|
};
|
|
|
|
|
2009-12-07 10:54:59 +08:00
|
|
|
/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
|
2009-08-19 09:28:17 +08:00
|
|
|
/// 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.
|
2010-02-12 11:41:30 +08:00
|
|
|
LocInfo = Type::TypeLast + 1
|
2009-08-19 09:28:17 +08:00
|
|
|
};
|
|
|
|
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *DeclInfo;
|
2009-08-19 09:28:17 +08:00
|
|
|
|
2009-12-07 10:54:59 +08:00
|
|
|
LocInfoType(QualType ty, TypeSourceInfo *TInfo)
|
|
|
|
: Type((TypeClass)LocInfo, ty, ty->isDependentType()), DeclInfo(TInfo) {
|
2009-08-19 09:28:17 +08:00
|
|
|
assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
|
|
|
|
}
|
|
|
|
friend class Sema;
|
|
|
|
|
|
|
|
public:
|
|
|
|
QualType getType() const { return getCanonicalTypeInternal(); }
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
|
2009-08-19 09:28:17 +08:00
|
|
|
|
|
|
|
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
|
2010-01-10 20:58:08 +08:00
|
|
|
mutable const TargetAttributesSema* TheTargetAttributesSema;
|
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-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
|
|
|
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
/// \brief Stack containing information about each of the nested function,
|
|
|
|
/// block, and method scopes that are currently active.
|
|
|
|
llvm::SmallVector<FunctionScopeInfo *, 4> FunctionScopes;
|
|
|
|
|
|
|
|
/// \brief Cached function scope object used for the top function scope
|
|
|
|
/// and when there is no function scope (in error cases).
|
2009-04-19 04:01:55 +08:00
|
|
|
///
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
/// This should never be accessed directly; rather, it's address will be
|
|
|
|
/// pushed into \c FunctionScopes when we want to re-use it.
|
|
|
|
FunctionScopeInfo TopFunctionScope;
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
2010-02-01 06:27:38 +08:00
|
|
|
/// \brief All the tentative definitions encountered in the TU.
|
|
|
|
std::vector<VarDecl *> TentativeDefinitions;
|
2009-04-22 01:11:58 +08:00
|
|
|
|
2010-02-12 08:07:30 +08:00
|
|
|
/// \brief The set of static functions seen so far that have not been used.
|
|
|
|
std::vector<FunctionDecl*> UnusedStaticFuncs;
|
2010-03-23 08:13:23 +08:00
|
|
|
|
2010-02-10 17:31:12 +08:00
|
|
|
class AccessedEntity {
|
|
|
|
public:
|
2010-03-16 13:22:47 +08:00
|
|
|
/// A member declaration found through lookup. The target is the
|
|
|
|
/// member.
|
|
|
|
enum MemberNonce { Member };
|
|
|
|
|
|
|
|
/// A hierarchy (base-to-derived or derived-to-base) conversion.
|
|
|
|
/// The target is the base class.
|
|
|
|
enum BaseNonce { Base };
|
|
|
|
|
|
|
|
bool isMemberAccess() const { return IsMember; }
|
|
|
|
|
2010-03-30 07:34:08 +08:00
|
|
|
AccessedEntity(ASTContext &Context,
|
|
|
|
MemberNonce _,
|
2010-03-16 13:22:47 +08:00
|
|
|
CXXRecordDecl *NamingClass,
|
2010-04-07 05:38:20 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
|
|
|
QualType BaseObjectType)
|
2010-03-19 15:35:19 +08:00
|
|
|
: Access(FoundDecl.getAccess()), IsMember(true),
|
|
|
|
Target(FoundDecl.getDecl()), NamingClass(NamingClass),
|
2010-04-07 05:38:20 +08:00
|
|
|
BaseObjectType(BaseObjectType), Diag(0, Context.getDiagAllocator()) {
|
2010-03-19 15:35:19 +08:00
|
|
|
}
|
|
|
|
|
2010-03-30 07:34:08 +08:00
|
|
|
AccessedEntity(ASTContext &Context,
|
|
|
|
BaseNonce _,
|
2010-03-16 13:22:47 +08:00
|
|
|
CXXRecordDecl *BaseClass,
|
|
|
|
CXXRecordDecl *DerivedClass,
|
|
|
|
AccessSpecifier Access)
|
|
|
|
: Access(Access), IsMember(false),
|
|
|
|
Target(BaseClass), NamingClass(DerivedClass),
|
2010-03-30 07:34:08 +08:00
|
|
|
Diag(0, Context.getDiagAllocator()) {
|
2010-02-10 17:31:12 +08:00
|
|
|
}
|
|
|
|
|
2010-03-16 13:22:47 +08:00
|
|
|
bool isQuiet() const { return Diag.getDiagID() == 0; }
|
|
|
|
|
2010-02-10 17:31:12 +08:00
|
|
|
AccessSpecifier getAccess() const { return AccessSpecifier(Access); }
|
|
|
|
|
|
|
|
// These apply to member decls...
|
|
|
|
NamedDecl *getTargetDecl() const { return Target; }
|
|
|
|
CXXRecordDecl *getNamingClass() const { return NamingClass; }
|
|
|
|
|
|
|
|
// ...and these apply to hierarchy conversions.
|
|
|
|
CXXRecordDecl *getBaseClass() const { return cast<CXXRecordDecl>(Target); }
|
|
|
|
CXXRecordDecl *getDerivedClass() const { return NamingClass; }
|
|
|
|
|
2010-04-07 05:38:20 +08:00
|
|
|
/// Retrieves the base object type, important when accessing
|
|
|
|
/// an instance member.
|
|
|
|
QualType getBaseObjectType() const { return BaseObjectType; }
|
|
|
|
|
2010-03-16 13:22:47 +08:00
|
|
|
/// Sets a diagnostic to be performed. The diagnostic is given
|
|
|
|
/// four (additional) arguments:
|
|
|
|
/// %0 - 0 if the entity was private, 1 if protected
|
|
|
|
/// %1 - the DeclarationName of the entity
|
|
|
|
/// %2 - the TypeDecl type of the naming class
|
|
|
|
/// %3 - the TypeDecl type of the declaring class
|
|
|
|
void setDiag(const PartialDiagnostic &PDiag) {
|
|
|
|
assert(isQuiet() && "partial diagnostic already defined");
|
|
|
|
Diag = PDiag;
|
|
|
|
}
|
|
|
|
PartialDiagnostic &setDiag(unsigned DiagID) {
|
|
|
|
assert(isQuiet() && "partial diagnostic already defined");
|
|
|
|
assert(DiagID && "creating null diagnostic");
|
2010-03-30 07:34:08 +08:00
|
|
|
Diag.Reset(DiagID);
|
2010-03-16 13:22:47 +08:00
|
|
|
return Diag;
|
|
|
|
}
|
|
|
|
const PartialDiagnostic &getDiag() const {
|
|
|
|
return Diag;
|
|
|
|
}
|
|
|
|
|
2010-02-10 17:31:12 +08:00
|
|
|
private:
|
|
|
|
unsigned Access : 2;
|
2010-03-16 13:22:47 +08:00
|
|
|
bool IsMember;
|
2010-02-10 17:31:12 +08:00
|
|
|
NamedDecl *Target;
|
|
|
|
CXXRecordDecl *NamingClass;
|
2010-04-07 05:38:20 +08:00
|
|
|
QualType BaseObjectType;
|
2010-03-16 13:22:47 +08:00
|
|
|
PartialDiagnostic Diag;
|
2010-02-10 17:31:12 +08:00
|
|
|
};
|
|
|
|
|
2010-01-27 11:50:35 +08:00
|
|
|
struct DelayedDiagnostic {
|
|
|
|
enum DDKind { Deprecation, Access };
|
|
|
|
|
|
|
|
unsigned char Kind; // actually a DDKind
|
|
|
|
bool Triggered;
|
|
|
|
|
|
|
|
SourceLocation Loc;
|
|
|
|
|
|
|
|
union {
|
|
|
|
/// Deprecation.
|
|
|
|
struct { NamedDecl *Decl; } DeprecationData;
|
|
|
|
|
|
|
|
/// Access control.
|
2010-03-16 13:22:47 +08:00
|
|
|
char AccessData[sizeof(AccessedEntity)];
|
2010-01-27 11:50:35 +08:00
|
|
|
};
|
|
|
|
|
2010-03-16 13:22:47 +08:00
|
|
|
void destroy() {
|
|
|
|
switch (Kind) {
|
|
|
|
case Access: getAccessData().~AccessedEntity(); break;
|
|
|
|
case Deprecation: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-27 11:50:35 +08:00
|
|
|
static DelayedDiagnostic makeDeprecation(SourceLocation Loc,
|
|
|
|
NamedDecl *D) {
|
|
|
|
DelayedDiagnostic DD;
|
|
|
|
DD.Kind = Deprecation;
|
|
|
|
DD.Triggered = false;
|
|
|
|
DD.Loc = Loc;
|
|
|
|
DD.DeprecationData.Decl = D;
|
|
|
|
return DD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DelayedDiagnostic makeAccess(SourceLocation Loc,
|
2010-02-10 17:31:12 +08:00
|
|
|
const AccessedEntity &Entity) {
|
2010-01-27 11:50:35 +08:00
|
|
|
DelayedDiagnostic DD;
|
|
|
|
DD.Kind = Access;
|
|
|
|
DD.Triggered = false;
|
|
|
|
DD.Loc = Loc;
|
2010-03-16 13:22:47 +08:00
|
|
|
new (&DD.getAccessData()) AccessedEntity(Entity);
|
2010-01-27 11:50:35 +08:00
|
|
|
return DD;
|
|
|
|
}
|
|
|
|
|
2010-03-16 13:22:47 +08:00
|
|
|
AccessedEntity &getAccessData() {
|
|
|
|
return *reinterpret_cast<AccessedEntity*>(AccessData);
|
|
|
|
}
|
|
|
|
const AccessedEntity &getAccessData() const {
|
|
|
|
return *reinterpret_cast<const AccessedEntity*>(AccessData);
|
|
|
|
}
|
2010-01-27 11:50:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief The stack of diagnostics that were delayed due to being
|
|
|
|
/// produced during the parsing of a declaration.
|
|
|
|
llvm::SmallVector<DelayedDiagnostic, 8> DelayedDiagnostics;
|
2009-11-04 10:18:39 +08:00
|
|
|
|
|
|
|
/// \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-11-26 08:44:06 +08:00
|
|
|
/// \brief The set of declarations that have been referenced within
|
|
|
|
/// a potentially evaluated expression.
|
|
|
|
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-12-12 15:57:52 +08:00
|
|
|
/// \brief A set of diagnostics that may be emitted.
|
|
|
|
typedef std::vector<std::pair<SourceLocation, PartialDiagnostic> >
|
|
|
|
PotentiallyEmittedDiagnostics;
|
|
|
|
|
2009-11-26 08:44:06 +08:00
|
|
|
/// \brief Data structure used to record current or nested
|
|
|
|
/// expression evaluation contexts.
|
|
|
|
struct ExpressionEvaluationContextRecord {
|
|
|
|
/// \brief The expression evaluation context.
|
|
|
|
ExpressionEvaluationContext Context;
|
|
|
|
|
|
|
|
/// \brief The number of temporaries that were active when we
|
|
|
|
/// entered this expression evaluation context.
|
|
|
|
unsigned NumTemporaries;
|
|
|
|
|
|
|
|
/// \brief The set of declarations referenced within a
|
|
|
|
/// potentially potentially-evaluated context.
|
|
|
|
///
|
|
|
|
/// When leaving a potentially potentially-evaluated context, each
|
|
|
|
/// of these elements will be as referenced if the corresponding
|
|
|
|
/// potentially potentially evaluated expression is potentially
|
|
|
|
/// evaluated.
|
|
|
|
PotentiallyReferencedDecls *PotentiallyReferenced;
|
|
|
|
|
2009-12-12 15:57:52 +08:00
|
|
|
/// \brief The set of diagnostics to emit should this potentially
|
|
|
|
/// potentially-evaluated context become evaluated.
|
|
|
|
PotentiallyEmittedDiagnostics *PotentiallyDiagnosed;
|
|
|
|
|
2009-11-26 08:44:06 +08:00
|
|
|
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context,
|
|
|
|
unsigned NumTemporaries)
|
|
|
|
: Context(Context), NumTemporaries(NumTemporaries),
|
2009-12-12 15:57:52 +08:00
|
|
|
PotentiallyReferenced(0), PotentiallyDiagnosed(0) { }
|
2009-11-26 08:44:06 +08:00
|
|
|
|
|
|
|
void addReferencedDecl(SourceLocation Loc, Decl *Decl) {
|
|
|
|
if (!PotentiallyReferenced)
|
|
|
|
PotentiallyReferenced = new PotentiallyReferencedDecls;
|
|
|
|
PotentiallyReferenced->push_back(std::make_pair(Loc, Decl));
|
|
|
|
}
|
|
|
|
|
2009-12-12 15:57:52 +08:00
|
|
|
void addDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) {
|
|
|
|
if (!PotentiallyDiagnosed)
|
|
|
|
PotentiallyDiagnosed = new PotentiallyEmittedDiagnostics;
|
|
|
|
PotentiallyDiagnosed->push_back(std::make_pair(Loc, PD));
|
|
|
|
}
|
|
|
|
|
2009-11-26 08:44:06 +08:00
|
|
|
void Destroy() {
|
|
|
|
delete PotentiallyReferenced;
|
2009-12-12 15:57:52 +08:00
|
|
|
delete PotentiallyDiagnosed;
|
2009-11-26 08:44:06 +08:00
|
|
|
PotentiallyReferenced = 0;
|
2009-12-12 15:57:52 +08:00
|
|
|
PotentiallyDiagnosed = 0;
|
2009-11-26 08:44:06 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// A stack of expression evaluation contexts.
|
|
|
|
llvm::SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts;
|
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);
|
2010-01-10 20:58:08 +08:00
|
|
|
~Sema();
|
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; }
|
2010-01-10 20:58:08 +08:00
|
|
|
const TargetAttributesSema &getTargetAttributesSema() const;
|
2008-11-22 16:28:49 +08:00
|
|
|
|
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.
|
2010-03-26 06:17:48 +08:00
|
|
|
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
|
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);
|
|
|
|
|
2010-03-30 07:34:08 +08:00
|
|
|
/// \brief Build a partial diagnostic.
|
|
|
|
PartialDiagnostic PDiag(unsigned DiagID = 0) {
|
|
|
|
return PartialDiagnostic(DiagID, Context.getDiagAllocator());
|
|
|
|
}
|
|
|
|
|
2007-08-31 12:53:24 +08:00
|
|
|
virtual void DeleteExpr(ExprTy *E);
|
|
|
|
virtual void DeleteStmt(StmtTy *S);
|
|
|
|
|
2009-12-01 06:42:35 +08:00
|
|
|
OwningExprResult Owned(Expr* E) {
|
|
|
|
assert(!E || E->isRetained());
|
|
|
|
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-12-01 06:42:35 +08:00
|
|
|
assert(!R.get() || ((Expr*) R.get())->isRetained());
|
2009-01-27 06:44:13 +08:00
|
|
|
return OwningExprResult(*this, R.get());
|
2009-01-19 08:08:26 +08:00
|
|
|
}
|
2009-12-01 06:42:35 +08:00
|
|
|
OwningStmtResult Owned(Stmt* S) {
|
|
|
|
assert(!S || S->isRetained());
|
|
|
|
return OwningStmtResult(*this, S);
|
|
|
|
}
|
2008-12-14 00:23:55 +08:00
|
|
|
|
2008-08-23 11:19:52 +08:00
|
|
|
virtual void ActOnEndOfTranslationUnit();
|
2009-01-20 06:31:54 +08:00
|
|
|
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
void PushFunctionScope();
|
|
|
|
void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
|
|
|
|
void PopFunctionOrBlockScope();
|
|
|
|
|
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() {
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
if (FunctionScopes.empty())
|
|
|
|
return TopFunctionScope.LabelMap;
|
|
|
|
|
|
|
|
return FunctionScopes.back()->LabelMap;
|
2009-04-19 04:01:55 +08:00
|
|
|
}
|
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() {
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
if (FunctionScopes.empty())
|
|
|
|
return TopFunctionScope.SwitchStack;
|
|
|
|
|
|
|
|
return FunctionScopes.back()->SwitchStack;
|
2009-04-19 04:10:59 +08:00
|
|
|
}
|
2009-07-31 10:52:19 +08:00
|
|
|
|
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.
The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.
Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.
llvm-svn: 97518
2010-03-02 07:15:13 +08:00
|
|
|
/// \brief Determine whether the current function or block needs scope
|
|
|
|
/// checking.
|
|
|
|
bool &FunctionNeedsScopeChecking() {
|
|
|
|
if (FunctionScopes.empty())
|
|
|
|
return TopFunctionScope.NeedsScopeChecking;
|
|
|
|
|
|
|
|
return FunctionScopes.back()->NeedsScopeChecking;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasAnyErrorsInThisFunction() const;
|
|
|
|
|
|
|
|
/// \brief Retrieve the current block, if any.
|
|
|
|
BlockScopeInfo *getCurBlock();
|
|
|
|
|
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
|
|
|
|
2006-11-12 06:59:23 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Type Analysis / Processing: SemaType.cpp.
|
|
|
|
//
|
2010-02-06 05:31:56 +08:00
|
|
|
|
2009-03-24 07:06:20 +08:00
|
|
|
QualType adjustParameterType(QualType T);
|
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,
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo **TInfo = 0,
|
2009-10-26 05:45:37 +08:00
|
|
|
TagDecl **OwnedDecl = 0);
|
2010-04-13 07:19:01 +08:00
|
|
|
TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T,
|
|
|
|
TypeSourceInfo *ReturnTypeInfo);
|
2009-12-07 10:54:59 +08:00
|
|
|
/// \brief Create a LocInfoType to hold the given QualType and TypeSourceInfo.
|
|
|
|
QualType CreateLocInfoType(QualType T, TypeSourceInfo *TInfo);
|
2008-11-18 06:58:34 +08:00
|
|
|
DeclarationName GetNameForDeclarator(Declarator &D);
|
2009-12-01 06:42:35 +08:00
|
|
|
DeclarationName GetNameFromUnqualifiedId(const UnqualifiedId &Name);
|
2009-12-07 10:54:59 +08:00
|
|
|
static QualType GetTypeFromParser(TypeTy *Ty, TypeSourceInfo **TInfo = 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);
|
2010-02-12 15:32:17 +08:00
|
|
|
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
|
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,
|
2010-02-12 15:32:17 +08:00
|
|
|
const FunctionProtoType *New, SourceLocation NewLoc,
|
2010-03-24 15:14:45 +08:00
|
|
|
bool *MissingExceptionSpecification = 0,
|
2010-02-12 15:32:17 +08:00
|
|
|
bool *MissingEmptyExceptionSpecification = 0);
|
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
|
|
|
|
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,
|
2010-03-30 07:34:08 +08:00
|
|
|
std::pair<SourceLocation, PartialDiagnostic> Note);
|
|
|
|
bool RequireCompleteType(SourceLocation Loc, QualType T,
|
|
|
|
const PartialDiagnostic &PD);
|
|
|
|
bool RequireCompleteType(SourceLocation Loc, QualType T,
|
|
|
|
unsigned DiagID);
|
|
|
|
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
Scope *S, 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,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec *SS,
|
2009-10-14 07:27:22 +08:00
|
|
|
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);
|
2010-03-22 17:20:08 +08:00
|
|
|
void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R);
|
|
|
|
void CheckShadow(Scope *S, VarDecl *D);
|
2009-01-20 09:17:11 +08:00
|
|
|
NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
2009-12-07 10:54:59 +08:00
|
|
|
QualType R, TypeSourceInfo *TInfo,
|
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-12-07 10:54:59 +08:00
|
|
|
QualType R, TypeSourceInfo *TInfo,
|
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-12-07 10:54:59 +08:00
|
|
|
QualType R, TypeSourceInfo *TInfo,
|
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-12-10 17:41:52 +08:00
|
|
|
void CheckFunctionDeclaration(Scope *S,
|
|
|
|
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);
|
Be sure to instantiate the parameters of a function, even when the
function's type is (strictly speaking) non-dependent. This ensures
that, e.g., default function arguments get instantiated properly.
And, since I couldn't resist, collapse the two implementations of
function-parameter instantiation into calls to a single, new function
(Sema::SubstParmVarDecl), since the two had nearly identical code (and
each had bugs the other didn't!). More importantly, factored out the
semantic analysis of a parameter declaration into
Sema::CheckParameter, which is called both by
Sema::ActOnParamDeclarator (when parameters are parsed) and when a
parameter is instantiated. Previously, we were missing some
Objective-C and address-space checks on instantiated function
parameters.
Fixes PR6733.
llvm-svn: 101029
2010-04-12 15:48:19 +08:00
|
|
|
ParmVarDecl *CheckParameter(DeclContext *DC,
|
|
|
|
TypeSourceInfo *TSInfo, QualType T,
|
|
|
|
IdentifierInfo *Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
VarDecl::StorageClass StorageClass);
|
2010-02-03 08:01:43 +08:00
|
|
|
virtual void ActOnObjCCatchParam(DeclPtrTy D);
|
2009-03-29 03:18:32 +08:00
|
|
|
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);
|
2010-03-31 10:13:20 +08:00
|
|
|
virtual void ActOnInitializerError(DeclPtrTy Dcl);
|
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) {
|
2010-04-08 04:29:57 +08:00
|
|
|
if (Diags.getDiagnosticLevel(diag::warn_unused_parameter) ==
|
|
|
|
Diagnostic::Ignored)
|
|
|
|
return;
|
|
|
|
|
2009-06-20 07:52:42 +08:00
|
|
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
SourceLocation KWLoc, CXXScopeSpec &SS,
|
2009-03-29 03:18:32 +08:00
|
|
|
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-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *TInfo,
|
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
|
|
|
|
2009-12-20 15:58:13 +08:00
|
|
|
/// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
|
|
|
|
/// C++ record definition's base-specifiers clause and are starting its
|
|
|
|
/// member declarations.
|
|
|
|
virtual void ActOnStartCXXMemberDeclarations(Scope *S, DeclPtrTy TagDecl,
|
|
|
|
SourceLocation LBraceLoc);
|
|
|
|
|
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
|
|
|
|
2010-03-17 08:38:33 +08:00
|
|
|
/// ActOnTagDefinitionError - Invoked when there was an unrecoverable
|
|
|
|
/// error parsing the definition of a tag.
|
|
|
|
virtual void ActOnTagDefinitionError(Scope *S, DeclPtrTy TagDecl);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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,
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *TInfo);
|
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
|
|
|
|
2009-12-16 11:45:30 +08:00
|
|
|
// AssignmentAction - This is used by all the assignment diagnostic functions
|
|
|
|
// to represent what is actually causing the operation
|
|
|
|
enum AssignmentAction {
|
|
|
|
AA_Assigning,
|
|
|
|
AA_Passing,
|
|
|
|
AA_Returning,
|
|
|
|
AA_Converting,
|
|
|
|
AA_Initializing,
|
|
|
|
AA_Sending,
|
|
|
|
AA_Casting
|
|
|
|
};
|
|
|
|
|
2008-10-22 00:13:35 +08:00
|
|
|
/// C++ Overloading.
|
2009-12-09 11:35:25 +08:00
|
|
|
enum OverloadKind {
|
|
|
|
/// This is a legitimate overload: the existing declarations are
|
|
|
|
/// functions or function templates with different signatures.
|
|
|
|
Ovl_Overload,
|
|
|
|
|
|
|
|
/// This is not an overload because the signature exactly matches
|
|
|
|
/// an existing declaration.
|
|
|
|
Ovl_Match,
|
|
|
|
|
|
|
|
/// This is not an overload because the lookup results contain a
|
|
|
|
/// non-function.
|
|
|
|
Ovl_NonFunction
|
|
|
|
};
|
|
|
|
OverloadKind CheckOverload(FunctionDecl *New,
|
2009-12-10 17:41:52 +08:00
|
|
|
const LookupResult &OldDecls,
|
2009-12-09 11:35:25 +08:00
|
|
|
NamedDecl *&OldDecl);
|
2009-11-19 06:49:29 +08:00
|
|
|
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-12-16 11:45:30 +08:00
|
|
|
|
Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:
- InitializationSequence now has a "C conversion sequence" category
and step kind, which falls back to
- Changed the diagnostics for returns to always have the result type
of the function first and the type of the expression second.
CheckSingleAssignmentConstraints to peform checking in C.
- Improved ASTs for initialization of return values. The ASTs now
capture all of the temporaries we need to create, but
intentionally do not bind the tempoary that is actually returned,
so that it won't get destroyed twice.
- Make sure to perform an (elidable!) copy of the class object that
is returned from a class.
- Fix copy elision in CodeGen to properly see through the
subexpressions that occur with elidable copies.
- Give "new" its own entity kind; as with return values and thrown
objects, we don't bind the expression so we don't call a
destructor for it.
Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.
llvm-svn: 91669
2009-12-18 13:02:21 +08:00
|
|
|
OwningExprResult PerformCopyInitialization(const InitializedEntity &Entity,
|
|
|
|
SourceLocation EqualLoc,
|
|
|
|
OwningExprResult Init);
|
2008-11-19 07:14:02 +08:00
|
|
|
ImplicitConversionSequence
|
2009-12-03 12:06:58 +08:00
|
|
|
TryObjectArgumentInitialization(QualType FromType, CXXMethodDecl *Method,
|
|
|
|
CXXRecordDecl *ActingContext);
|
2010-03-04 07:55:11 +08:00
|
|
|
bool PerformObjectArgumentInitialization(Expr *&From,
|
|
|
|
NestedNameSpecifier *Qualifier,
|
2010-03-31 05:47:33 +08:00
|
|
|
NamedDecl *FoundDecl,
|
2010-03-04 07:55:11 +08:00
|
|
|
CXXMethodDecl *Method);
|
2008-11-19 07:14:02 +08:00
|
|
|
|
2009-01-14 23:45:31 +08:00
|
|
|
ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
|
|
|
|
bool PerformContextuallyConvertToBool(Expr *&From);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-03-04 07:55:11 +08:00
|
|
|
bool PerformObjectMemberConversion(Expr *&From,
|
|
|
|
NestedNameSpecifier *Qualifier,
|
2010-03-31 05:47:33 +08:00
|
|
|
NamedDecl *FoundDecl,
|
2010-03-04 07:55:11 +08:00
|
|
|
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-03-14 02:40:31 +08:00
|
|
|
typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
|
|
|
|
|
2010-01-26 11:27:55 +08:00
|
|
|
void AddOverloadCandidate(NamedDecl *Function,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2010-01-26 11:27:55 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet &CandidateSet);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
void AddOverloadCandidate(FunctionDecl *Function,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
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);
|
2010-01-26 11:27:55 +08:00
|
|
|
void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
|
2009-03-14 02:40:31 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversions = false);
|
2010-03-19 15:35:19 +08:00
|
|
|
void AddMethodCandidate(DeclAccessPair FoundDecl,
|
2010-01-26 09:37:31 +08:00
|
|
|
QualType ObjectType,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-11-17 15:50:12 +08:00
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversion = false,
|
|
|
|
bool ForceRValue = false);
|
2010-03-19 15:35:19 +08:00
|
|
|
void AddMethodCandidate(CXXMethodDecl *Method,
|
|
|
|
DeclAccessPair FoundDecl,
|
2010-01-26 09:37:31 +08:00
|
|
|
CXXRecordDecl *ActingContext, QualType ObjectType,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2008-11-19 07:14:02 +08:00
|
|
|
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,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2009-12-03 12:06:58 +08:00
|
|
|
CXXRecordDecl *ActingContext,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
2009-12-03 12:06:58 +08:00
|
|
|
QualType ObjectType,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-08-21 08:16:32 +08:00
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool SuppressUserConversions = false,
|
|
|
|
bool ForceRValue = false);
|
2009-06-26 06:08:12 +08:00
|
|
|
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
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,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2009-12-03 12:06:58 +08:00
|
|
|
CXXRecordDecl *ActingContext,
|
2008-11-08 06:36:19 +08:00
|
|
|
Expr *From, QualType ToType,
|
|
|
|
OverloadCandidateSet& CandidateSet);
|
2009-08-22 07:19:43 +08:00
|
|
|
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2009-12-03 12:06:58 +08:00
|
|
|
CXXRecordDecl *ActingContext,
|
2009-08-22 07:19:43 +08:00
|
|
|
Expr *From, QualType ToType,
|
|
|
|
OverloadCandidateSet &CandidateSet);
|
2008-11-20 06:57:39 +08:00
|
|
|
void AddSurrogateCandidate(CXXConversionDecl *Conversion,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2009-12-03 12:06:58 +08:00
|
|
|
CXXRecordDecl *ActingContext,
|
2009-02-27 07:50:07 +08:00
|
|
|
const FunctionProtoType *Proto,
|
2009-12-03 12:06:58 +08:00
|
|
|
QualType ObjectTy, Expr **Args, unsigned NumArgs,
|
2008-11-20 06:57:39 +08:00
|
|
|
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,
|
2010-01-26 11:27:55 +08:00
|
|
|
bool Operator,
|
2009-02-04 08:32:51 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
2009-09-22 23:41:20 +08:00
|
|
|
OverloadCandidateSet& CandidateSet,
|
|
|
|
bool PartialOverloading = false);
|
2008-10-22 00:13:35 +08:00
|
|
|
bool isBetterOverloadCandidate(const OverloadCandidate& Cand1,
|
2010-02-09 07:07:23 +08:00
|
|
|
const OverloadCandidate& Cand2,
|
|
|
|
SourceLocation Loc);
|
2008-10-22 00:13:35 +08:00
|
|
|
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);
|
2010-01-08 12:41:39 +08:00
|
|
|
|
|
|
|
enum OverloadCandidateDisplayKind {
|
|
|
|
/// Requests that all candidates be shown. Viable candidates will
|
|
|
|
/// be printed first.
|
|
|
|
OCD_AllCandidates,
|
|
|
|
|
|
|
|
/// Requests that only viable candidates be shown.
|
|
|
|
OCD_ViableCandidates
|
|
|
|
};
|
2008-10-22 00:13:35 +08:00
|
|
|
void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
|
2010-01-08 12:41:39 +08:00
|
|
|
OverloadCandidateDisplayKind OCD,
|
2010-01-12 15:18:19 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
2010-01-08 12:41:39 +08:00
|
|
|
const char *Opc = 0,
|
|
|
|
SourceLocation Loc = SourceLocation());
|
|
|
|
|
2010-01-06 17:43:14 +08:00
|
|
|
void NoteOverloadCandidate(FunctionDecl *Fn);
|
2010-01-12 08:44:57 +08:00
|
|
|
void DiagnoseAmbiguousConversion(const ImplicitConversionSequence &ICS,
|
|
|
|
SourceLocation CaretLoc,
|
|
|
|
const PartialDiagnostic &PDiag);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-11 04:40:00 +08:00
|
|
|
FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
|
2010-03-31 05:47:33 +08:00
|
|
|
bool Complain,
|
|
|
|
DeclAccessPair &Found);
|
2009-12-22 07:17:24 +08:00
|
|
|
FunctionDecl *ResolveSingleFunctionTemplateSpecialization(Expr *From);
|
|
|
|
|
2010-03-31 05:47:33 +08:00
|
|
|
Expr *FixOverloadedFunctionReference(Expr *E,
|
2010-04-07 05:38:20 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2010-03-31 05:47:33 +08:00
|
|
|
FunctionDecl *Fn);
|
2009-12-10 07:02:17 +08:00
|
|
|
OwningExprResult FixOverloadedFunctionReference(OwningExprResult,
|
2010-04-07 05:38:20 +08:00
|
|
|
DeclAccessPair FoundDecl,
|
2009-12-10 07:02:17 +08:00
|
|
|
FunctionDecl *Fn);
|
2008-11-11 04:40:00 +08:00
|
|
|
|
2009-12-16 20:17:52 +08:00
|
|
|
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
|
2009-09-22 23:41:20 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
OverloadCandidateSet &CandidateSet,
|
|
|
|
bool PartialOverloading = false);
|
|
|
|
|
2009-12-16 20:17:52 +08:00
|
|
|
OwningExprResult BuildOverloadedCallExpr(Expr *Fn,
|
2009-12-16 22:20:08 +08:00
|
|
|
UnresolvedLookupExpr *ULE,
|
2009-12-16 20:17:52 +08:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc);
|
2009-03-14 02:40:31 +08:00
|
|
|
|
2009-03-14 07:49:33 +08:00
|
|
|
OwningExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
|
|
|
|
unsigned Opc,
|
2010-01-26 11:27:55 +08:00
|
|
|
const UnresolvedSetImpl &Fns,
|
2009-03-14 07:49:33 +08:00
|
|
|
ExprArg input);
|
|
|
|
|
2009-03-14 02:40:31 +08:00
|
|
|
OwningExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
|
|
|
|
unsigned Opc,
|
2010-01-26 11:27:55 +08:00
|
|
|
const UnresolvedSetImpl &Fns,
|
2009-03-14 02:40:31 +08:00
|
|
|
Expr *LHS, Expr *RHS);
|
|
|
|
|
2009-10-30 04:17:01 +08:00
|
|
|
OwningExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
|
|
|
|
SourceLocation RLoc,
|
|
|
|
ExprArg Base,ExprArg Idx);
|
|
|
|
|
2009-12-02 06:10:20 +08:00
|
|
|
OwningExprResult
|
2008-12-22 13:46:06 +08:00
|
|
|
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.
|
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-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
|
2009-12-21 09:26:45 +08:00
|
|
|
/// operator in C++. This lookup completely ignores operator, object,
|
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
|
|
|
/// 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-12-10 17:41:52 +08:00
|
|
|
/// Look up all declarations in a scope with the given name,
|
|
|
|
/// including resolved using declarations. This is appropriate
|
|
|
|
/// for checking redeclarations for a using declaration.
|
|
|
|
LookupUsingDeclName,
|
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
|
2009-12-11 08:26:36 +08:00
|
|
|
LookupObjCImplementationName
|
2009-01-15 06:20:51 +08:00
|
|
|
};
|
|
|
|
|
2010-01-12 02:40:55 +08:00
|
|
|
/// \brief Specifies whether (or how) name lookup is being performed for a
|
|
|
|
/// redeclaration (vs. a reference).
|
2009-11-18 15:57:50 +08:00
|
|
|
enum RedeclarationKind {
|
2010-01-12 02:40:55 +08:00
|
|
|
/// \brief The lookup is a reference to this name that is not for the
|
|
|
|
/// purpose of redeclaring the name.
|
|
|
|
NotForRedeclaration = 0,
|
|
|
|
/// \brief The lookup results will be used for redeclaration of a name,
|
|
|
|
/// if an entity by that name already exists.
|
2009-11-18 15:57:50 +08:00
|
|
|
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:
|
2009-10-10 05:13:30 +08:00
|
|
|
/// \brief Look up a name, looking for a single declaration. Return
|
2009-12-02 16:25:40 +08:00
|
|
|
/// null if the results were absent, ambiguous, or overloaded.
|
2009-10-10 05:13:30 +08:00
|
|
|
///
|
|
|
|
/// 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);
|
2010-01-15 09:44:47 +08:00
|
|
|
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
|
|
|
|
bool InUnqualifiedLookup = false);
|
2010-04-09 00:38:48 +08:00
|
|
|
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
|
2009-10-10 05:13:30 +08:00
|
|
|
bool AllowBuiltinCreation = false,
|
|
|
|
bool EnteringContext = false);
|
2009-04-24 07:18:26 +08:00
|
|
|
ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II);
|
|
|
|
|
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,
|
2010-01-26 11:27:55 +08:00
|
|
|
UnresolvedSetImpl &Functions);
|
2009-12-31 01:04:44 +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,
|
2010-01-26 15:16:45 +08:00
|
|
|
ADLResult &Functions);
|
2009-03-13 08:33:25 +08:00
|
|
|
|
2009-12-31 01:04:44 +08:00
|
|
|
void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
|
|
|
|
VisibleDeclConsumer &Consumer);
|
|
|
|
void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
|
|
|
|
VisibleDeclConsumer &Consumer);
|
|
|
|
|
2010-04-09 00:38:48 +08:00
|
|
|
bool CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS,
|
2009-12-31 15:42:17 +08:00
|
|
|
DeclContext *MemberContext = 0,
|
2010-01-04 02:01:57 +08:00
|
|
|
bool EnteringContext = false,
|
|
|
|
const ObjCObjectPointerType *OPT = 0);
|
2009-12-31 01:04:44 +08:00
|
|
|
|
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
|
|
|
|
2010-01-04 02:01:57 +08:00
|
|
|
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
|
|
|
|
SourceLocation RecoverLoc = SourceLocation());
|
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,
|
2010-04-01 02:23:33 +08:00
|
|
|
bool &IncompleteImpl, unsigned DiagID);
|
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,
|
2010-03-28 05:10:05 +08:00
|
|
|
ObjCContainerDecl *CDecl);
|
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
|
|
|
|
2010-01-20 09:51:55 +08:00
|
|
|
/// DiagnoseUnimplementedProperties - This routine warns on those properties
|
|
|
|
/// which must be implemented by this implementation.
|
|
|
|
void DiagnoseUnimplementedProperties(ObjCImplDecl* IMPDecl,
|
|
|
|
ObjCContainerDecl *CDecl,
|
|
|
|
const llvm::DenseSet<Selector>& InsMap);
|
2010-03-12 10:31:10 +08:00
|
|
|
|
2010-01-20 09:51:55 +08:00
|
|
|
/// CollectImmediateProperties - This routine collects all properties in
|
|
|
|
/// the class and its conforming protocols; but not those it its super class.
|
|
|
|
void CollectImmediateProperties(ObjCContainerDecl *CDecl,
|
|
|
|
llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap);
|
|
|
|
|
2010-02-10 03:31:38 +08:00
|
|
|
/// LookupPropertyDecl - Looks up a property in the current class and all
|
|
|
|
/// its protocols.
|
|
|
|
ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl,
|
|
|
|
IdentifierInfo *II);
|
|
|
|
|
2010-03-12 10:31:10 +08:00
|
|
|
/// Called by ActOnProperty to handle @property declarations in
|
|
|
|
//// class extensions.
|
|
|
|
DeclPtrTy HandlePropertyInClassExtension(Scope *S,
|
|
|
|
ObjCCategoryDecl *CDecl,
|
|
|
|
SourceLocation AtLoc,
|
|
|
|
FieldDeclarator &FD,
|
|
|
|
Selector GetterSel,
|
|
|
|
Selector SetterSel,
|
|
|
|
const bool isAssign,
|
|
|
|
const bool isReadWrite,
|
|
|
|
const unsigned Attributes,
|
|
|
|
bool *isOverridingProperty,
|
|
|
|
QualType T,
|
|
|
|
tok::ObjCKeywordKind MethodImplKind);
|
|
|
|
|
|
|
|
/// Called by ActOnProperty and HandlePropertyInClassExtension to
|
|
|
|
/// handle creating the ObjcPropertyDecl for a category or @interface.
|
|
|
|
ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
|
|
|
|
ObjCContainerDecl *CDecl,
|
|
|
|
SourceLocation AtLoc,
|
|
|
|
FieldDeclarator &FD,
|
|
|
|
Selector GetterSel,
|
|
|
|
Selector SetterSel,
|
|
|
|
const bool isAssign,
|
|
|
|
const bool isReadWrite,
|
|
|
|
const unsigned Attributes, QualType T,
|
|
|
|
tok::ObjCKeywordKind MethodImplKind);
|
|
|
|
|
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
|
|
|
|
2010-02-24 07:41:11 +08:00
|
|
|
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
|
|
|
|
|
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,
|
2009-11-25 08:27:52 +08:00
|
|
|
FullExprArg CondVal, DeclPtrTy CondVar,
|
|
|
|
StmtArg ThenVal,
|
2009-05-18 02:26:53 +08:00
|
|
|
SourceLocation ElseLoc, StmtArg ElseVal);
|
2009-11-25 08:27:52 +08:00
|
|
|
virtual OwningStmtResult ActOnStartOfSwitchStmt(FullExprArg Cond,
|
|
|
|
DeclPtrTy CondVar);
|
2010-01-24 09:50:29 +08:00
|
|
|
virtual void ActOnSwitchBodyError(SourceLocation SwitchLoc, StmtArg Switch,
|
|
|
|
StmtArg Body);
|
2009-01-11 08:38:46 +08:00
|
|
|
virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
|
|
|
|
StmtArg Switch, StmtArg Body);
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
|
2009-11-25 08:27:52 +08:00
|
|
|
FullExprArg Cond,
|
|
|
|
DeclPtrTy CondVar, 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,
|
2009-11-25 08:27:52 +08:00
|
|
|
StmtArg First, FullExprArg Second,
|
|
|
|
DeclPtrTy SecondVar,
|
|
|
|
FullExprArg Third,
|
|
|
|
SourceLocation RParenLoc,
|
2009-01-17 07:28:06 +08:00
|
|
|
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,
|
2010-01-31 06:25:16 +08:00
|
|
|
IdentifierInfo **Names,
|
2009-01-19 00:53:17 +08:00
|
|
|
MultiExprArg Constraints,
|
|
|
|
MultiExprArg Exprs,
|
|
|
|
ExprArg AsmString,
|
|
|
|
MultiExprArg Clobbers,
|
2010-01-05 06:37:17 +08:00
|
|
|
SourceLocation RParenLoc,
|
|
|
|
bool MSAsm = false);
|
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-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *TInfo,
|
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);
|
|
|
|
|
2010-01-27 11:50:35 +08:00
|
|
|
void HandleDelayedDeprecationCheck(DelayedDiagnostic &DD, Decl *Ctx);
|
|
|
|
|
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-26 08:44:06 +08:00
|
|
|
virtual void
|
2009-06-23 04:57:11 +08:00
|
|
|
PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-26 08:44:06 +08:00
|
|
|
virtual void PopExpressionEvaluationContext();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-20 07:52:42 +08:00
|
|
|
void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
|
2009-12-22 09:01:55 +08:00
|
|
|
bool DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD);
|
|
|
|
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-11-04 00:56:39 +08:00
|
|
|
UnqualifiedId &Name,
|
|
|
|
bool HasTrailingLParen,
|
|
|
|
bool IsAddressOfOperand);
|
2009-11-25 03:00:30 +08:00
|
|
|
|
2010-04-09 00:38:48 +08:00
|
|
|
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R);
|
2009-12-16 16:11:27 +08:00
|
|
|
|
2009-11-25 03:00:30 +08:00
|
|
|
OwningExprResult LookupInObjCMethod(LookupResult &R,
|
|
|
|
Scope *S,
|
2010-01-13 07:58:59 +08:00
|
|
|
IdentifierInfo *II,
|
|
|
|
bool AllowBuiltinCreation=false);
|
2009-11-25 03:00:30 +08:00
|
|
|
|
|
|
|
OwningExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
|
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
2009-12-02 11:53:29 +08:00
|
|
|
bool isAddressOfOperand,
|
2009-11-25 03:00:30 +08:00
|
|
|
const TemplateArgumentListInfo *TemplateArgs);
|
2009-11-04 00:56:39 +08:00
|
|
|
|
2009-12-08 17:08:17 +08:00
|
|
|
OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
|
2009-11-23 19:41:28 +08:00
|
|
|
SourceLocation Loc,
|
2009-06-24 08:10:43 +08:00
|
|
|
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-12-16 20:17:52 +08:00
|
|
|
OwningExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
|
|
|
|
LookupResult &R,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs);
|
2009-12-02 06:10:20 +08:00
|
|
|
OwningExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
|
|
|
|
LookupResult &R,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs,
|
|
|
|
bool IsDefiniteInstance);
|
2009-11-25 03:00:30 +08:00
|
|
|
bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
|
2009-11-22 09:44:31 +08:00
|
|
|
const LookupResult &R,
|
|
|
|
bool HasTrailingLParen);
|
2009-11-25 03:00:30 +08:00
|
|
|
|
2010-04-09 00:38:48 +08:00
|
|
|
OwningExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
|
2009-11-25 03:00:30 +08:00
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc);
|
|
|
|
OwningExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
|
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs);
|
|
|
|
|
|
|
|
OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
|
|
|
|
LookupResult &R,
|
|
|
|
bool ADL);
|
|
|
|
OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
|
2009-11-21 16:51:07 +08:00
|
|
|
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-11-25 09:26:41 +08:00
|
|
|
virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L,
|
2009-08-11 07:49:36 +08:00
|
|
|
SourceLocation R,
|
2009-11-25 09:26:41 +08:00
|
|
|
MultiExprArg Val,
|
|
|
|
TypeTy *TypeOfCast=0);
|
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-12-07 10:54:59 +08:00
|
|
|
OwningExprResult CreateSizeOfAlignOfExpr(TypeSourceInfo *T,
|
2009-11-04 15:28:41 +08:00
|
|
|
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
|
|
|
|
2009-12-01 06:42:35 +08:00
|
|
|
OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
|
2009-12-02 06:10:20 +08:00
|
|
|
QualType BaseType,
|
2009-09-01 08:37:14 +08:00
|
|
|
SourceLocation OpLoc,
|
2009-12-01 06:42:35 +08:00
|
|
|
bool IsArrow,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-12-01 06:42:35 +08:00
|
|
|
NamedDecl *FirstQualifierInScope,
|
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs);
|
|
|
|
|
|
|
|
OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
|
2009-12-02 06:10:20 +08:00
|
|
|
QualType BaseType,
|
2009-12-01 06:42:35 +08:00
|
|
|
SourceLocation OpLoc, bool IsArrow,
|
|
|
|
const CXXScopeSpec &SS,
|
2010-01-15 16:34:02 +08:00
|
|
|
NamedDecl *FirstQualifierInScope,
|
2009-12-01 06:42:35 +08:00
|
|
|
LookupResult &R,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs);
|
|
|
|
|
|
|
|
OwningExprResult LookupMemberExpr(LookupResult &R, Expr *&Base,
|
2009-12-08 06:46:59 +08:00
|
|
|
bool &IsArrow, SourceLocation OpLoc,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-12-01 06:42:35 +08:00
|
|
|
DeclPtrTy ObjCImpDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-12-01 06:42:35 +08:00
|
|
|
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
|
2009-12-02 11:53:29 +08:00
|
|
|
const CXXScopeSpec &SS,
|
2009-12-01 06:42:35 +08:00
|
|
|
const LookupResult &R);
|
|
|
|
|
|
|
|
OwningExprResult ActOnDependentMemberExpr(ExprArg Base,
|
2009-12-02 06:10:20 +08:00
|
|
|
QualType BaseType,
|
2009-12-01 06:42:35 +08:00
|
|
|
bool IsArrow,
|
2009-08-27 02:25:21 +08:00
|
|
|
SourceLocation OpLoc,
|
2009-12-01 06:42:35 +08:00
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
NamedDecl *FirstQualifierInScope,
|
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs);
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-11-04 03:44:04 +08:00
|
|
|
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
|
|
|
|
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-12-02 06:10:20 +08:00
|
|
|
OwningExprResult BuildResolvedCallExpr(Expr *Fn,
|
|
|
|
NamedDecl *NDecl,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation RParenLoc);
|
2009-01-19 08:08:26 +08:00
|
|
|
|
2009-08-11 07:49:36 +08:00
|
|
|
virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
|
|
|
|
TypeTy *Ty, SourceLocation RParenLoc,
|
|
|
|
ExprArg Op);
|
2010-01-16 02:56:44 +08:00
|
|
|
OwningExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
|
|
|
|
TypeSourceInfo *Ty,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
ExprArg Op);
|
|
|
|
|
2009-11-24 03:51:43 +08:00
|
|
|
virtual bool TypeIsVectorType(TypeTy *Ty) {
|
|
|
|
return GetTypeFromParser(Ty)->isVectorType();
|
|
|
|
}
|
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,
|
2010-01-19 03:35:47 +08:00
|
|
|
TypeSourceInfo *TInfo);
|
2009-01-20 06:31:54 +08:00
|
|
|
|
|
|
|
virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
|
|
|
|
TypeTy *Ty,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
ExprArg Op);
|
|
|
|
|
2010-01-19 03:35:47 +08:00
|
|
|
OwningExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
|
|
|
|
TypeSourceInfo *TInfo,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
ExprArg InitExpr);
|
|
|
|
|
2009-01-20 06:31:54 +08:00
|
|
|
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,
|
2010-02-07 09:09:23 +08:00
|
|
|
SourceLocation LBrace,
|
|
|
|
AttributeList *AttrList);
|
2009-03-29 03:18:32 +08:00
|
|
|
virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace);
|
|
|
|
|
|
|
|
virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
|
|
|
|
SourceLocation UsingLoc,
|
|
|
|
SourceLocation NamespcLoc,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-03-29 03:18:32 +08:00
|
|
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-03-29 06:53:22 +08:00
|
|
|
SourceLocation IdentLoc,
|
|
|
|
IdentifierInfo *Ident);
|
2009-06-20 08:51:54 +08:00
|
|
|
|
2009-12-10 17:41:52 +08:00
|
|
|
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
|
|
|
|
bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
|
|
|
|
const LookupResult &PreviousDecls);
|
|
|
|
UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
|
|
|
|
NamedDecl *Target);
|
|
|
|
|
|
|
|
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
|
|
|
|
bool isTypeName,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
const LookupResult &Previous);
|
2009-12-05 06:46:56 +08:00
|
|
|
bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
SourceLocation NameLoc);
|
|
|
|
|
2009-11-17 13:59:44 +08:00
|
|
|
NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
|
|
|
|
SourceLocation UsingLoc,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-08-28 13:40:36 +08:00
|
|
|
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-12-11 10:10:03 +08:00
|
|
|
bool HasUsingKeyword,
|
2009-08-28 13:40:36 +08:00
|
|
|
SourceLocation UsingLoc,
|
2010-04-09 00:38:48 +08:00
|
|
|
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-12-17 02:50:27 +08:00
|
|
|
MultiExprArg Exprs,
|
Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:
- CXXBaseOrMemberInitializer now contains only a single initializer
rather than a set of initialiation arguments + a constructor. The
single initializer covers all aspects of initialization, including
constructor calls as necessary but also cleanup of temporaries
created by the initializer (which we never handled
before!).
- Rework + simplify code generation for CXXBaseOrMemberInitializers,
since we can now just emit the initializer as an initializer.
- Switched base and member initialization over to the new
initialization code (InitializationSequence), so that it
- Improved diagnostics for the new initialization code when
initializing bases and members, to match the diagnostics produced
by the previous (special-purpose) code.
- Simplify the representation of type-checked constructor initializers in
templates; instead of keeping the fully-type-checked AST, which is
rather hard to undo at template instantiation time, throw away the
type-checked AST and store the raw expressions in the AST. This
simplifies instantiation, but loses a little but of information in
the AST.
- When type-checking implicit base or member initializers within a
dependent context, don't add the generated initializers into the
AST, because they'll look like they were explicit.
- Record in CXXConstructExpr when the constructor call is to
initialize a base class, so that CodeGen does not have to infer it
from context. This ensures that we call the right kind of
constructor.
There are also a few "opportunity" fixes here that were needed to not
regress, for example:
- Diagnose default-initialization of a const-qualified class that
does not have a user-declared default constructor. We had this
diagnostic specifically for bases and members, but missed it for
variables. That's fixed now.
- When defining the implicit constructors, destructor, and
copy-assignment operator, set the CurContext to that constructor
when we're defining the body.
llvm-svn: 94952
2010-01-31 17:12:51 +08:00
|
|
|
bool RequiresZeroInit = false,
|
|
|
|
bool BaseInitialization = false);
|
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-12-17 02:50:27 +08:00
|
|
|
MultiExprArg Exprs,
|
Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:
- CXXBaseOrMemberInitializer now contains only a single initializer
rather than a set of initialiation arguments + a constructor. The
single initializer covers all aspects of initialization, including
constructor calls as necessary but also cleanup of temporaries
created by the initializer (which we never handled
before!).
- Rework + simplify code generation for CXXBaseOrMemberInitializers,
since we can now just emit the initializer as an initializer.
- Switched base and member initialization over to the new
initialization code (InitializationSequence), so that it
- Improved diagnostics for the new initialization code when
initializing bases and members, to match the diagnostics produced
by the previous (special-purpose) code.
- Simplify the representation of type-checked constructor initializers in
templates; instead of keeping the fully-type-checked AST, which is
rather hard to undo at template instantiation time, throw away the
type-checked AST and store the raw expressions in the AST. This
simplifies instantiation, but loses a little but of information in
the AST.
- When type-checking implicit base or member initializers within a
dependent context, don't add the generated initializers into the
AST, because they'll look like they were explicit.
- Record in CXXConstructExpr when the constructor call is to
initialize a base class, so that CodeGen does not have to infer it
from context. This ensures that we call the right kind of
constructor.
There are also a few "opportunity" fixes here that were needed to not
regress, for example:
- Diagnose default-initialization of a const-qualified class that
does not have a user-declared default constructor. We had this
diagnostic specifically for bases and members, but missed it for
variables. That's fixed now.
- When defining the implicit constructors, destructor, and
copy-assignment operator, set the CurContext to that constructor
when we're defining the body.
llvm-svn: 94952
2010-01-31 17:12:51 +08:00
|
|
|
bool RequiresZeroInit = false,
|
|
|
|
bool BaseInitialization = false);
|
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.
|
2010-02-02 17:10:11 +08:00
|
|
|
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *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.
|
2009-12-09 11:01:51 +08:00
|
|
|
CXXMethodDecl *getAssignOperatorMethod(SourceLocation CurrentLocation,
|
|
|
|
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
|
|
|
|
2009-11-14 11:27:21 +08:00
|
|
|
CXXConstructorDecl *
|
|
|
|
TryInitializationByConstructor(QualType ClassType,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation Loc,
|
|
|
|
InitializationKind Kind);
|
2009-09-10 07:08:42 +08:00
|
|
|
|
|
|
|
bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
|
|
|
|
MultiExprArg ArgsPtr,
|
|
|
|
SourceLocation Loc,
|
|
|
|
ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs);
|
|
|
|
|
2010-02-17 03:09:40 +08:00
|
|
|
virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
|
|
|
|
IdentifierInfo &II, SourceLocation NameLoc,
|
2010-04-09 00:38:48 +08:00
|
|
|
Scope *S, CXXScopeSpec &SS,
|
2010-02-17 03:09:40 +08:00
|
|
|
TypeTy *ObjectType,
|
|
|
|
bool EnteringContext);
|
|
|
|
|
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
|
|
|
|
2010-01-16 03:13:16 +08:00
|
|
|
OwningExprResult BuildCXXNamedCast(SourceLocation OpLoc,
|
|
|
|
tok::TokenKind Kind,
|
|
|
|
TypeSourceInfo *Ty,
|
|
|
|
ExprArg E,
|
|
|
|
SourceRange AngleBrackets,
|
|
|
|
SourceRange Parens);
|
|
|
|
|
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,
|
2009-12-17 00:59:22 +08:00
|
|
|
QualType Argument,
|
|
|
|
bool addMallocAttr = false);
|
2008-11-22 03:14:01 +08:00
|
|
|
|
2009-11-16 02:45:20 +08:00
|
|
|
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
|
2009-12-03 01:15:43 +08:00
|
|
|
DeclarationName Name, FunctionDecl* &Operator);
|
2009-11-16 02:45:20 +08:00
|
|
|
|
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
|
|
|
|
2009-11-25 08:27:52 +08:00
|
|
|
virtual DeclResult ActOnCXXConditionDeclaration(Scope *S,
|
|
|
|
Declarator &D);
|
2009-11-24 07:44:04 +08:00
|
|
|
OwningExprResult CheckConditionVariable(VarDecl *ConditionVar);
|
|
|
|
|
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,
|
Rework parsing of pseudo-destructor expressions and explicit
destructor calls, e.g.,
p->T::~T
We now detect when the member access that we've parsed, e.g.,
p-> or x.
may be a pseudo-destructor expression, either because the type of p or
x is a scalar or because it is dependent (and, therefore, may become a
scalar at template instantiation time).
We then parse the pseudo-destructor grammar specifically:
::[opt] nested-name-specifier[opt] type-name :: ∼ type-name
and hand those results to a new action, ActOnPseudoDestructorExpr,
which will cope with both dependent member accesses of destructors and
with pseudo-destructor expressions.
This commit affects the parsing of pseudo-destructors, only; the
semantic actions still go through the semantic actions for member
access expressions. That will change soon.
llvm-svn: 97045
2010-02-25 02:44:31 +08:00
|
|
|
TypeTy *&ObjectType,
|
|
|
|
bool &MayBePseudoDestructor);
|
|
|
|
|
2010-02-25 05:29:12 +08:00
|
|
|
OwningExprResult DiagnoseDtorReference(SourceLocation NameLoc,
|
|
|
|
ExprArg MemExpr);
|
|
|
|
|
2010-02-25 06:38:50 +08:00
|
|
|
OwningExprResult BuildPseudoDestructorExpr(ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
|
|
|
const CXXScopeSpec &SS,
|
|
|
|
TypeSourceInfo *ScopeType,
|
|
|
|
SourceLocation CCLoc,
|
2010-02-25 07:50:37 +08:00
|
|
|
SourceLocation TildeLoc,
|
2010-02-25 09:56:36 +08:00
|
|
|
PseudoDestructorTypeStorage DestroyedType,
|
2010-02-25 06:38:50 +08:00
|
|
|
bool HasTrailingLParen);
|
2010-02-25 09:56:36 +08:00
|
|
|
|
Rework parsing of pseudo-destructor expressions and explicit
destructor calls, e.g.,
p->T::~T
We now detect when the member access that we've parsed, e.g.,
p-> or x.
may be a pseudo-destructor expression, either because the type of p or
x is a scalar or because it is dependent (and, therefore, may become a
scalar at template instantiation time).
We then parse the pseudo-destructor grammar specifically:
::[opt] nested-name-specifier[opt] type-name :: ∼ type-name
and hand those results to a new action, ActOnPseudoDestructorExpr,
which will cope with both dependent member accesses of destructors and
with pseudo-destructor expressions.
This commit affects the parsing of pseudo-destructors, only; the
semantic actions still go through the semantic actions for member
access expressions. That will change soon.
llvm-svn: 97045
2010-02-25 02:44:31 +08:00
|
|
|
virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
tok::TokenKind OpKind,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
Rework parsing of pseudo-destructor expressions and explicit
destructor calls, e.g.,
p->T::~T
We now detect when the member access that we've parsed, e.g.,
p-> or x.
may be a pseudo-destructor expression, either because the type of p or
x is a scalar or because it is dependent (and, therefore, may become a
scalar at template instantiation time).
We then parse the pseudo-destructor grammar specifically:
::[opt] nested-name-specifier[opt] type-name :: ∼ type-name
and hand those results to a new action, ActOnPseudoDestructorExpr,
which will cope with both dependent member accesses of destructors and
with pseudo-destructor expressions.
This commit affects the parsing of pseudo-destructors, only; the
semantic actions still go through the semantic actions for member
access expressions. That will change soon.
llvm-svn: 97045
2010-02-25 02:44:31 +08:00
|
|
|
UnqualifiedId &FirstTypeName,
|
|
|
|
SourceLocation CCLoc,
|
|
|
|
SourceLocation TildeLoc,
|
|
|
|
UnqualifiedId &SecondTypeName,
|
|
|
|
bool HasTrailingLParen);
|
2010-02-25 05:29:12 +08:00
|
|
|
|
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-12-16 04:51:39 +08:00
|
|
|
Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
|
2009-12-23 06:17:25 +08:00
|
|
|
OwningExprResult MaybeCreateCXXExprWithTemporaries(OwningExprResult SubExpr);
|
2009-12-16 10:09:40 +08:00
|
|
|
FullExpr CreateFullExpr(Expr *SubExpr);
|
|
|
|
|
2009-05-18 02:41:29 +08:00
|
|
|
virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
|
|
|
|
|
2010-04-09 00:38:48 +08:00
|
|
|
// Marks SS invalid if it represents an incomplete type.
|
|
|
|
bool RequireCompleteDeclContext(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);
|
|
|
|
|
2010-02-25 12:46:04 +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
|
|
|
|
2010-04-09 00:38:48 +08:00
|
|
|
virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
|
2010-02-25 05:29:12 +08:00
|
|
|
SourceLocation IdLoc,
|
|
|
|
IdentifierInfo &II,
|
|
|
|
TypeTy *ObjectType);
|
|
|
|
|
2009-09-04 05:38:09 +08:00
|
|
|
CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-09-04 05:38:09 +08:00
|
|
|
SourceLocation IdLoc,
|
|
|
|
SourceLocation CCLoc,
|
|
|
|
IdentifierInfo &II,
|
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *ScopeLookupResult,
|
2009-12-07 09:36:53 +08:00
|
|
|
bool EnteringContext,
|
|
|
|
bool ErrorRecoveryLookup);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-09 01:17:31 +08:00
|
|
|
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2008-11-09 01:17:31 +08:00
|
|
|
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
|
|
|
|
2009-12-07 09:36:53 +08:00
|
|
|
virtual bool IsInvalidUnlessNestedName(Scope *S,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-12-07 09:36:53 +08:00
|
|
|
IdentifierInfo &II,
|
|
|
|
TypeTy *ObjectType,
|
|
|
|
bool EnteringContext);
|
|
|
|
|
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,
|
2010-02-25 12:46:04 +08:00
|
|
|
SourceLocation CCLoc);
|
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
|
|
|
|
2009-12-12 04:04:54 +08:00
|
|
|
virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
|
|
|
|
|
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.
|
2010-04-09 00:38:48 +08:00
|
|
|
virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, 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);
|
2010-03-31 05:47:33 +08:00
|
|
|
CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp,
|
|
|
|
NamedDecl *FoundDecl,
|
|
|
|
CXXMethodDecl *Method);
|
2009-09-29 07:23:40 +08:00
|
|
|
|
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-11-25 07:38:44 +08:00
|
|
|
ExprTy *Init, bool IsDefinition,
|
2009-04-13 01:16:29 +08:00
|
|
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
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,
|
2009-12-03 06:36:29 +08:00
|
|
|
SourceLocation LParenLoc,
|
2009-07-30 03:44:27 +08:00
|
|
|
SourceLocation RParenLoc);
|
|
|
|
|
2009-12-03 06:36:29 +08:00
|
|
|
MemInitResult BuildBaseInitializer(QualType BaseType,
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *BaseTInfo,
|
2009-12-03 06:36:29 +08:00
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
SourceLocation LParenLoc,
|
2009-07-30 03:44:27 +08:00
|
|
|
SourceLocation RParenLoc,
|
|
|
|
CXXRecordDecl *ClassDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-10 04:14:44 +08:00
|
|
|
bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
|
Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:
- CXXBaseOrMemberInitializer now contains only a single initializer
rather than a set of initialiation arguments + a constructor. The
single initializer covers all aspects of initialization, including
constructor calls as necessary but also cleanup of temporaries
created by the initializer (which we never handled
before!).
- Rework + simplify code generation for CXXBaseOrMemberInitializers,
since we can now just emit the initializer as an initializer.
- Switched base and member initialization over to the new
initialization code (InitializationSequence), so that it
- Improved diagnostics for the new initialization code when
initializing bases and members, to match the diagnostics produced
by the previous (special-purpose) code.
- Simplify the representation of type-checked constructor initializers in
templates; instead of keeping the fully-type-checked AST, which is
rather hard to undo at template instantiation time, throw away the
type-checked AST and store the raw expressions in the AST. This
simplifies instantiation, but loses a little but of information in
the AST.
- When type-checking implicit base or member initializers within a
dependent context, don't add the generated initializers into the
AST, because they'll look like they were explicit.
- Record in CXXConstructExpr when the constructor call is to
initialize a base class, so that CodeGen does not have to infer it
from context. This ensures that we call the right kind of
constructor.
There are also a few "opportunity" fixes here that were needed to not
regress, for example:
- Diagnose default-initialization of a const-qualified class that
does not have a user-declared default constructor. We had this
diagnostic specifically for bases and members, but missed it for
variables. That's fixed now.
- When defining the implicit constructors, destructor, and
copy-assignment operator, set the CurContext to that constructor
when we're defining the body.
llvm-svn: 94952
2010-01-31 17:12:51 +08:00
|
|
|
CXXBaseOrMemberInitializer **Initializers,
|
2010-04-02 11:43:34 +08:00
|
|
|
unsigned NumInitializers, bool AnyErrors);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-03-17 05:39:52 +08:00
|
|
|
/// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
|
|
|
|
/// mark all the non-trivial destructors of its members and bases as
|
|
|
|
/// referenced.
|
|
|
|
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
|
|
|
|
CXXRecordDecl *Record);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-12-07 16:24:59 +08:00
|
|
|
/// ClassesWithUnmarkedVirtualMembers - Contains record decls whose virtual
|
2010-01-06 12:44:19 +08:00
|
|
|
/// members need to be marked as referenced at the end of the translation
|
|
|
|
/// unit. It will contain polymorphic classes that do not have a key
|
|
|
|
/// function or have a key function that has been defined.
|
|
|
|
llvm::SmallVector<std::pair<CXXRecordDecl *, SourceLocation>, 4>
|
|
|
|
ClassesWithUnmarkedVirtualMembers;
|
2009-12-07 16:24:59 +08:00
|
|
|
|
|
|
|
/// MaybeMarkVirtualMembersReferenced - If the passed in method is the
|
2009-12-03 01:15:43 +08:00
|
|
|
/// key function of the record decl, will mark virtual member functions as
|
|
|
|
/// referenced.
|
2009-12-07 16:24:59 +08:00
|
|
|
void MaybeMarkVirtualMembersReferenced(SourceLocation Loc, CXXMethodDecl *MD);
|
|
|
|
|
|
|
|
/// MarkVirtualMembersReferenced - Will mark all virtual members of the given
|
|
|
|
/// CXXRecordDecl referenced.
|
2010-03-26 08:36:59 +08:00
|
|
|
void MarkVirtualMembersReferenced(SourceLocation Loc,
|
|
|
|
const CXXRecordDecl *RD);
|
2009-12-07 16:24:59 +08:00
|
|
|
|
|
|
|
/// ProcessPendingClassesWithUnmarkedVirtualMembers - Will process classes
|
|
|
|
/// that might need to have their virtual members marked as referenced.
|
|
|
|
/// Returns false if no work was done.
|
|
|
|
bool ProcessPendingClassesWithUnmarkedVirtualMembers();
|
2009-12-03 01:15:43 +08:00
|
|
|
|
2010-04-13 01:09:20 +08:00
|
|
|
void AddImplicitlyDeclaredMembersToClass(Scope *S, CXXRecordDecl *ClassDecl);
|
2008-11-04 01:51:48 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
|
2009-03-25 10:58:17 +08:00
|
|
|
SourceLocation ColonLoc,
|
Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:
- CXXBaseOrMemberInitializer now contains only a single initializer
rather than a set of initialiation arguments + a constructor. The
single initializer covers all aspects of initialization, including
constructor calls as necessary but also cleanup of temporaries
created by the initializer (which we never handled
before!).
- Rework + simplify code generation for CXXBaseOrMemberInitializers,
since we can now just emit the initializer as an initializer.
- Switched base and member initialization over to the new
initialization code (InitializationSequence), so that it
- Improved diagnostics for the new initialization code when
initializing bases and members, to match the diagnostics produced
by the previous (special-purpose) code.
- Simplify the representation of type-checked constructor initializers in
templates; instead of keeping the fully-type-checked AST, which is
rather hard to undo at template instantiation time, throw away the
type-checked AST and store the raw expressions in the AST. This
simplifies instantiation, but loses a little but of information in
the AST.
- When type-checking implicit base or member initializers within a
dependent context, don't add the generated initializers into the
AST, because they'll look like they were explicit.
- Record in CXXConstructExpr when the constructor call is to
initialize a base class, so that CodeGen does not have to infer it
from context. This ensures that we call the right kind of
constructor.
There are also a few "opportunity" fixes here that were needed to not
regress, for example:
- Diagnose default-initialization of a const-qualified class that
does not have a user-declared default constructor. We had this
diagnostic specifically for bases and members, but missed it for
variables. That's fixed now.
- When defining the implicit constructors, destructor, and
copy-assignment operator, set the CurContext to that constructor
when we're defining the body.
llvm-svn: 94952
2010-01-31 17:12:51 +08:00
|
|
|
MemInitTy **MemInits, unsigned NumMemInits,
|
|
|
|
bool AnyErrors);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-04-13 01:09:20 +08:00
|
|
|
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record);
|
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,
|
2010-03-29 22:42:08 +08:00
|
|
|
SourceLocation RBrac,
|
|
|
|
AttributeList *AttrList);
|
2008-07-01 18:37:29 +08:00
|
|
|
|
2009-05-28 07:11:45 +08:00
|
|
|
virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template);
|
2009-12-19 18:49:29 +08:00
|
|
|
virtual void ActOnStartDelayedMemberDeclarations(Scope *S,
|
|
|
|
DeclPtrTy Record);
|
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);
|
2009-12-19 18:49:29 +08:00
|
|
|
virtual void ActOnFinishDelayedMemberDeclarations(Scope *S,
|
|
|
|
DeclPtrTy Record);
|
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
|
|
|
|
2010-04-08 00:53:43 +08:00
|
|
|
FriendDecl *CheckFriendTypeDecl(SourceLocation FriendLoc,
|
|
|
|
TypeSourceInfo *TSInfo);
|
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-12-03 01:15:43 +08:00
|
|
|
bool 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);
|
2009-10-22 15:08:30 +08:00
|
|
|
|
2008-10-23 08:40:37 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Derived Classes
|
|
|
|
//
|
|
|
|
|
|
|
|
/// ActOnBaseSpecifier - Parsed a base specifier
|
2009-03-03 12:44:36 +08:00
|
|
|
CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
|
|
|
|
SourceRange SpecifierRange,
|
|
|
|
bool Virtual, AccessSpecifier Access,
|
2009-09-09 23:08:12 +08:00
|
|
|
QualType BaseType,
|
2009-03-03 12:44:36 +08:00
|
|
|
SourceLocation BaseLoc);
|
2009-12-04 01:49:57 +08:00
|
|
|
|
|
|
|
/// SetClassDeclAttributesFromBase - Copies class decl traits
|
|
|
|
/// (such as whether the class has a trivial constructor,
|
|
|
|
/// trivial destructor etc) from the given base class.
|
|
|
|
void SetClassDeclAttributesFromBase(CXXRecordDecl *Class,
|
|
|
|
const CXXRecordDecl *BaseClass,
|
|
|
|
bool BaseIsVirtual);
|
|
|
|
|
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,
|
2010-03-16 13:22:47 +08:00
|
|
|
unsigned InaccessibleBaseID,
|
2009-05-14 05:11:42 +08:00
|
|
|
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-12-02 01:24:26 +08:00
|
|
|
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
|
2009-03-27 13:05:05 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Access Control
|
|
|
|
//
|
2009-07-18 22:32:15 +08:00
|
|
|
|
2010-02-10 17:31:12 +08:00
|
|
|
enum AccessResult {
|
|
|
|
AR_accessible,
|
|
|
|
AR_inaccessible,
|
|
|
|
AR_dependent,
|
|
|
|
AR_delayed
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2010-02-10 17:31:12 +08:00
|
|
|
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl);
|
2010-02-10 17:31:12 +08:00
|
|
|
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl);
|
2010-03-18 16:19:33 +08:00
|
|
|
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
|
|
|
|
SourceRange PlacementRange,
|
|
|
|
CXXRecordDecl *NamingClass,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl);
|
2010-02-10 17:31:12 +08:00
|
|
|
AccessResult CheckConstructorAccess(SourceLocation Loc,
|
|
|
|
CXXConstructorDecl *D,
|
|
|
|
AccessSpecifier Access);
|
|
|
|
AccessResult CheckDestructorAccess(SourceLocation Loc,
|
2010-03-16 13:22:47 +08:00
|
|
|
CXXDestructorDecl *Dtor,
|
|
|
|
const PartialDiagnostic &PDiag);
|
2010-03-16 14:11:48 +08:00
|
|
|
AccessResult CheckDirectMemberAccess(SourceLocation Loc,
|
|
|
|
NamedDecl *D,
|
|
|
|
const PartialDiagnostic &PDiag);
|
2010-02-10 17:31:12 +08:00
|
|
|
AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
|
|
|
|
Expr *ObjectExpr,
|
2010-03-16 13:22:47 +08:00
|
|
|
Expr *ArgExpr,
|
2010-03-19 15:35:19 +08:00
|
|
|
DeclAccessPair FoundDecl);
|
2010-03-31 05:47:33 +08:00
|
|
|
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
|
|
|
|
DeclAccessPair FoundDecl);
|
2010-02-10 17:31:12 +08:00
|
|
|
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
|
|
|
|
QualType Base, QualType Derived,
|
|
|
|
const CXXBasePath &Path,
|
2010-03-16 13:22:47 +08:00
|
|
|
unsigned DiagID,
|
2010-02-10 17:31:12 +08:00
|
|
|
bool ForceCheck = false,
|
2010-03-16 13:22:47 +08:00
|
|
|
bool ForceUnprivileged = false);
|
2010-02-10 17:31:12 +08:00
|
|
|
void CheckLookupAccess(const LookupResult &R);
|
2010-01-23 08:46:32 +08:00
|
|
|
|
2010-03-24 13:22:00 +08:00
|
|
|
void HandleDependentAccessCheck(const DependentDiagnostic &DD,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
|
|
|
void PerformDependentDiagnostics(const DeclContext *Pattern,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
|
|
|
|
2010-01-27 11:50:35 +08:00
|
|
|
void HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *Ctx);
|
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);
|
|
|
|
|
2010-01-13 17:01:02 +08:00
|
|
|
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
|
|
|
|
|
2008-12-06 02:15:24 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// C++ Templates [C++ 14]
|
|
|
|
//
|
2010-04-09 00:38:48 +08:00
|
|
|
void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
|
2009-11-25 03:00:30 +08:00
|
|
|
QualType ObjectType, bool EnteringContext);
|
|
|
|
|
2009-09-03 06:59:36 +08:00
|
|
|
virtual TemplateNameKind isTemplateName(Scope *S,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-11-04 07:16:33 +08:00
|
|
|
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);
|
2010-01-13 05:28:44 +08:00
|
|
|
|
|
|
|
virtual bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
|
|
|
|
SourceLocation IILoc,
|
|
|
|
Scope *S,
|
|
|
|
const CXXScopeSpec *SS,
|
|
|
|
TemplateTy &SuggestedTemplate,
|
|
|
|
TemplateNameKind &SuggestedKind);
|
|
|
|
|
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-11-26 01:50:39 +08:00
|
|
|
|
|
|
|
/// \brief The context in which we are checking a template parameter
|
|
|
|
/// list.
|
|
|
|
enum TemplateParamListContext {
|
|
|
|
TPC_ClassTemplate,
|
|
|
|
TPC_FunctionTemplate,
|
|
|
|
TPC_ClassTemplateMember,
|
|
|
|
TPC_FriendFunctionTemplate
|
|
|
|
};
|
|
|
|
|
2009-02-11 03:49:53 +08:00
|
|
|
bool CheckTemplateParameterList(TemplateParameterList *NewParams,
|
2009-11-26 01:50:39 +08:00
|
|
|
TemplateParameterList *OldParams,
|
|
|
|
TemplateParamListContext TPC);
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
SourceLocation KWLoc, CXXScopeSpec &SS,
|
2009-07-24 00:36:45 +08:00
|
|
|
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-11-23 09:53:49 +08:00
|
|
|
void translateTemplateArguments(const ASTTemplateArgsPtr &In,
|
|
|
|
TemplateArgumentListInfo &Out);
|
2009-09-26 07:53:26 +08:00
|
|
|
|
2009-03-31 06:58:21 +08:00
|
|
|
QualType CheckTemplateIdType(TemplateName Template,
|
|
|
|
SourceLocation TemplateLoc,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo &TemplateArgs);
|
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-11-25 03:00:30 +08:00
|
|
|
OwningExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
|
|
|
|
LookupResult &R,
|
|
|
|
bool RequiresADL,
|
|
|
|
const TemplateArgumentListInfo &TemplateArgs);
|
2010-04-09 00:38:48 +08:00
|
|
|
OwningExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
|
2009-11-25 03:00:30 +08:00
|
|
|
DeclarationName Name,
|
|
|
|
SourceLocation NameLoc,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo &TemplateArgs);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-31 08:43:58 +08:00
|
|
|
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
|
2010-04-09 00:38:48 +08:00
|
|
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
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);
|
|
|
|
|
2010-04-08 17:05:18 +08:00
|
|
|
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
|
|
|
|
const TemplateArgumentListInfo &ExplicitTemplateArgs,
|
|
|
|
LookupResult &Previous);
|
|
|
|
|
2009-09-25 07:14:47 +08:00
|
|
|
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
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,
|
2010-04-09 00:38:48 +08:00
|
|
|
CXXScopeSpec &SS,
|
2009-05-14 08:28:11 +08:00
|
|
|
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-26 02:55:14 +08:00
|
|
|
TemplateArgumentLoc
|
|
|
|
SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
Decl *Param,
|
|
|
|
TemplateArgumentListBuilder &Converted);
|
|
|
|
|
2010-03-28 10:42:43 +08:00
|
|
|
/// \brief Specifies the context in which a particular template
|
|
|
|
/// argument is being checked.
|
|
|
|
enum CheckTemplateArgumentKind {
|
|
|
|
/// \brief The template argument was specified in the code or was
|
|
|
|
/// instantiated with some deduced template arguments.
|
|
|
|
CTAK_Specified,
|
|
|
|
|
|
|
|
/// \brief The template argument was deduced via template argument
|
|
|
|
/// deduction.
|
|
|
|
CTAK_Deduced,
|
|
|
|
|
|
|
|
/// \brief The template argument was deduced from an array bound
|
|
|
|
/// via template argument deduction.
|
|
|
|
CTAK_DeducedFromArrayBound
|
|
|
|
};
|
|
|
|
|
2009-11-12 03:31:23 +08:00
|
|
|
bool CheckTemplateArgument(NamedDecl *Param,
|
|
|
|
const TemplateArgumentLoc &Arg,
|
|
|
|
TemplateDecl *Template,
|
|
|
|
SourceLocation TemplateLoc,
|
|
|
|
SourceLocation RAngleLoc,
|
2010-03-28 10:42:43 +08:00
|
|
|
TemplateArgumentListBuilder &Converted,
|
|
|
|
CheckTemplateArgumentKind CTAK = CTAK_Specified);
|
2009-11-12 03:31:23 +08:00
|
|
|
|
2009-02-10 07:23:08 +08:00
|
|
|
bool CheckTemplateArgumentList(TemplateDecl *Template,
|
|
|
|
SourceLocation TemplateLoc,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo &TemplateArgs,
|
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,
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *Arg);
|
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,
|
2010-03-28 10:42:43 +08:00
|
|
|
TemplateArgument &Converted,
|
|
|
|
CheckTemplateArgumentKind CTAK = CTAK_Specified);
|
2009-11-11 09:00:40 +08:00
|
|
|
bool CheckTemplateArgument(TemplateTemplateParmDecl *Param,
|
|
|
|
const TemplateArgumentLoc &Arg);
|
2010-03-28 10:42:43 +08:00
|
|
|
|
|
|
|
OwningExprResult
|
|
|
|
BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
|
|
|
|
QualType ParamType,
|
|
|
|
SourceLocation Loc);
|
|
|
|
OwningExprResult
|
|
|
|
BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
|
|
|
|
SourceLocation Loc);
|
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.
|
2009-12-22 07:17:24 +08:00
|
|
|
TDK_InvalidExplicitArguments,
|
|
|
|
/// \brief The arguments included an overloaded function name that could
|
|
|
|
/// not be resolved to a suitable function.
|
|
|
|
TDK_FailedOverloadResolution
|
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;
|
|
|
|
|
2010-02-09 07:07:23 +08:00
|
|
|
/// \brief The source location at which template argument
|
|
|
|
/// deduction is occurring.
|
|
|
|
SourceLocation Loc;
|
|
|
|
|
2009-06-13 02:26:56 +08:00
|
|
|
// do not implement these
|
|
|
|
TemplateDeductionInfo(const TemplateDeductionInfo&);
|
|
|
|
TemplateDeductionInfo &operator=(const TemplateDeductionInfo&);
|
|
|
|
|
|
|
|
public:
|
2010-02-09 07:07:23 +08:00
|
|
|
TemplateDeductionInfo(ASTContext &Context, SourceLocation Loc)
|
|
|
|
: Context(Context), Deduced(0), Loc(Loc) { }
|
2009-06-13 02:26:56 +08:00
|
|
|
|
|
|
|
~TemplateDeductionInfo() {
|
|
|
|
// FIXME: if (Deduced) Deduced->Destroy(Context);
|
|
|
|
}
|
|
|
|
|
2010-02-09 07:07:23 +08:00
|
|
|
/// \brief Returns the location at which template argument is
|
|
|
|
/// occuring.
|
|
|
|
SourceLocation getLocation() const {
|
|
|
|
return Loc;
|
|
|
|
}
|
|
|
|
|
2009-06-13 02:26:56 +08:00
|
|
|
/// \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-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo &ExplicitTemplateArgs,
|
2010-03-28 10:42:43 +08:00
|
|
|
llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
|
2009-07-09 04:55:45 +08:00
|
|
|
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,
|
2010-03-28 10:42:43 +08:00
|
|
|
llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
|
|
|
|
unsigned NumExplicitlySpecified,
|
2009-07-09 04:55:45 +08:00
|
|
|
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-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
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,
|
2009-11-23 09:53:49 +08:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
2009-07-09 04:55:45 +08:00
|
|
|
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);
|
|
|
|
|
2009-12-22 07:17:24 +08:00
|
|
|
TemplateDeductionResult
|
|
|
|
DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
|
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
|
|
|
FunctionDecl *&Specialization,
|
|
|
|
TemplateDeductionInfo &Info);
|
|
|
|
|
2009-08-22 07:19:43 +08:00
|
|
|
FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
|
|
|
|
FunctionTemplateDecl *FT2,
|
2010-02-09 07:07:23 +08:00
|
|
|
SourceLocation Loc,
|
2009-09-15 02:39:43 +08:00
|
|
|
TemplatePartialOrderingContext TPOC);
|
2010-01-27 09:50:18 +08:00
|
|
|
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin,
|
|
|
|
UnresolvedSetIterator SEnd,
|
|
|
|
TemplatePartialOrderingContext TPOC,
|
|
|
|
SourceLocation Loc,
|
|
|
|
const PartialDiagnostic &NoneDiag,
|
|
|
|
const PartialDiagnostic &AmbigDiag,
|
|
|
|
const PartialDiagnostic &CandidateDiag);
|
2009-09-26 02:43:00 +08:00
|
|
|
|
2009-09-16 00:23:51 +08:00
|
|
|
ClassTemplatePartialSpecializationDecl *
|
|
|
|
getMoreSpecializedPartialSpecialization(
|
|
|
|
ClassTemplatePartialSpecializationDecl *PS1,
|
2010-02-09 07:07:23 +08:00
|
|
|
ClassTemplatePartialSpecializationDecl *PS2,
|
|
|
|
SourceLocation Loc);
|
2009-09-16 00:23:51 +08:00
|
|
|
|
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,
|
2010-02-05 15:33:43 +08:00
|
|
|
const TemplateArgumentList *Innermost = 0,
|
|
|
|
bool RelativeToPrimary = false);
|
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;
|
|
|
|
|
2010-01-17 06:29:39 +08:00
|
|
|
/// \brief Whether we have already exited this scope.
|
|
|
|
bool Exited;
|
|
|
|
|
2010-03-25 23:38:42 +08:00
|
|
|
/// \brief Whether this scope is temporary, meaning that we should
|
|
|
|
/// remove any additions we make once we exit this
|
|
|
|
/// scope. Temporary scopes are always combined with their outer
|
|
|
|
/// scopes.
|
|
|
|
bool Temporary;
|
|
|
|
|
|
|
|
/// \brief List of the declarations that we have added into this
|
|
|
|
/// temporary scope. They will be removed when we exit the
|
|
|
|
/// temporary scope.
|
|
|
|
llvm::SmallVector<const Decl *, 4> AddedTemporaryDecls;
|
|
|
|
|
2009-05-15 05:44:34 +08:00
|
|
|
// This class is non-copyable
|
|
|
|
LocalInstantiationScope(const LocalInstantiationScope &);
|
|
|
|
LocalInstantiationScope &operator=(const LocalInstantiationScope &);
|
|
|
|
|
|
|
|
public:
|
2010-03-25 23:38:42 +08:00
|
|
|
LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false,
|
|
|
|
bool Temporary = false)
|
2010-01-17 06:29:39 +08:00
|
|
|
: SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
|
2010-03-25 23:38:42 +08:00
|
|
|
Exited(false), Temporary(Temporary) {
|
|
|
|
if (!CombineWithOuterScope && !Temporary)
|
2009-11-01 01:21:17 +08:00
|
|
|
SemaRef.CurrentInstantiationScope = this;
|
|
|
|
else
|
|
|
|
assert(SemaRef.CurrentInstantiationScope &&
|
|
|
|
"No outer instantiation scope?");
|
2009-05-15 05:44:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~LocalInstantiationScope() {
|
2010-03-25 23:38:42 +08:00
|
|
|
if (!Exited) {
|
2010-01-17 06:29:39 +08:00
|
|
|
SemaRef.CurrentInstantiationScope = Outer;
|
2010-03-25 23:38:42 +08:00
|
|
|
for (unsigned I = 0, N = AddedTemporaryDecls.size(); I != N; ++I)
|
|
|
|
LocalDecls.erase(AddedTemporaryDecls[I]);
|
|
|
|
}
|
2010-01-17 06:29:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Exit this local instantiation scope early.
|
|
|
|
void Exit() {
|
2009-05-15 05:44:34 +08:00
|
|
|
SemaRef.CurrentInstantiationScope = Outer;
|
2010-01-17 06:29:39 +08:00
|
|
|
LocalDecls.clear();
|
|
|
|
Exited = true;
|
2009-05-15 05:44:34 +08:00
|
|
|
}
|
|
|
|
|
2009-05-27 13:35:12 +08:00
|
|
|
Decl *getInstantiationOf(const Decl *D) {
|
|
|
|
Decl *Result = LocalDecls[D];
|
2010-03-02 02:27:54 +08:00
|
|
|
assert((Result || D->isInvalidDecl()) &&
|
|
|
|
"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];
|
2010-03-02 03:00:07 +08:00
|
|
|
assert((!Stored || Stored == Inst) && "Already instantiated this local");
|
2010-03-25 23:38:42 +08:00
|
|
|
|
|
|
|
if (Temporary && !Stored)
|
|
|
|
AddedTemporaryDecls.push_back(D);
|
|
|
|
|
2009-05-27 13:35:12 +08:00
|
|
|
Stored = Inst;
|
2009-05-15 05:44:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief The current instantiation scope used to store local
|
|
|
|
/// variables.
|
|
|
|
LocalInstantiationScope *CurrentInstantiationScope;
|
|
|
|
|
2010-02-02 10:07:01 +08:00
|
|
|
/// \brief The number of typos corrected by CorrectTypo.
|
|
|
|
unsigned TyposCorrected;
|
|
|
|
|
2010-03-23 08:13:23 +08:00
|
|
|
/// \brief Worker object for performing CFG-based warnings.
|
|
|
|
sema::AnalysisBasedWarnings AnalysisWarnings;
|
|
|
|
|
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
|
|
|
|
2010-01-17 06:29:39 +08:00
|
|
|
/// \brief The queue of implicit template instantiations that are required
|
|
|
|
/// and must be performed within the current local scope.
|
|
|
|
///
|
|
|
|
/// This queue is only used for member functions of local classes in
|
|
|
|
/// templates, which must be instantiated in the same scope as their
|
|
|
|
/// enclosing function, so that they can reference function-local
|
|
|
|
/// types, static variables, enumerators, etc.
|
|
|
|
std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
|
|
|
|
|
|
|
|
void PerformPendingImplicitInstantiations(bool LocalOnly = false);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *SubstType(TypeSourceInfo *T,
|
2009-10-21 08:58:09 +08:00
|
|
|
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
|
|
|
|
2010-04-10 01:38:44 +08:00
|
|
|
TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs,
|
|
|
|
SourceLocation Loc,
|
|
|
|
DeclarationName Entity);
|
Be sure to instantiate the parameters of a function, even when the
function's type is (strictly speaking) non-dependent. This ensures
that, e.g., default function arguments get instantiated properly.
And, since I couldn't resist, collapse the two implementations of
function-parameter instantiation into calls to a single, new function
(Sema::SubstParmVarDecl), since the two had nearly identical code (and
each had bugs the other didn't!). More importantly, factored out the
semantic analysis of a parameter declaration into
Sema::CheckParameter, which is called both by
Sema::ActOnParamDeclarator (when parameters are parsed) and when a
parameter is instantiated. Previously, we were missing some
Objective-C and address-space checks on instantiated function
parameters.
Fixes PR6733.
llvm-svn: 101029
2010-04-12 15:48:19 +08:00
|
|
|
ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
|
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
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
|
|
|
|
2010-03-01 23:56:25 +08:00
|
|
|
NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
|
2009-09-17 02:34:49 +08:00
|
|
|
const MultiLevelTemplateArgumentList &TemplateArgs);
|
2010-03-01 23:56:25 +08:00
|
|
|
DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
|
2009-09-17 02:34:49 +08:00
|
|
|
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,
|
2010-01-16 23:02:53 +08:00
|
|
|
const SourceLocation *ProtoLocs,
|
2009-03-29 03:18:32 +08:00
|
|
|
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,
|
2010-01-16 23:02:53 +08:00
|
|
|
const SourceLocation *ProtoLocs,
|
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,
|
2010-01-16 23:02:53 +08:00
|
|
|
const SourceLocation *ProtoLocs,
|
2009-03-29 03:18:32 +08:00
|
|
|
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.
|
2010-03-31 06:40:11 +08:00
|
|
|
void CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
|
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
|
|
|
|
2010-01-19 02:41:16 +08:00
|
|
|
void CompareProperties(Decl *CDecl, 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
|
|
|
|
2010-01-19 02:41:16 +08:00
|
|
|
void MatchOneProtocolPropertiesInClass(Decl *CDecl,
|
|
|
|
ObjCProtocolDecl *PDecl);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-01-07 09:20:12 +08:00
|
|
|
virtual void ActOnAtEnd(SourceRange AtEnd,
|
|
|
|
DeclPtrTy classDecl,
|
|
|
|
DeclPtrTy *allMethods = 0, unsigned allNum = 0,
|
|
|
|
DeclPtrTy *allProperties = 0, unsigned pNum = 0,
|
|
|
|
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,
|
2010-04-08 08:30:06 +08:00
|
|
|
DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args
|
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
|
|
|
|
2010-04-11 16:28:14 +08:00
|
|
|
OwningExprResult
|
2010-04-11 15:45:24 +08:00
|
|
|
HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
|
2010-04-11 15:51:10 +08:00
|
|
|
Expr *BaseExpr,
|
2010-04-11 15:45:24 +08:00
|
|
|
DeclarationName MemberName,
|
2010-04-11 15:51:10 +08:00
|
|
|
SourceLocation MemberLoc);
|
2010-04-11 15:45:24 +08:00
|
|
|
|
2010-04-11 16:28:14 +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
|
|
|
|
2010-02-03 08:27:59 +08:00
|
|
|
// DefaultFunctionArrayLvalueConversion - converts functions and
|
|
|
|
// arrays to their respective pointers and performs the
|
|
|
|
// lvalue-to-rvalue conversion.
|
|
|
|
void DefaultFunctionArrayLvalueConversion(Expr *&expr);
|
|
|
|
|
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,
|
2009-11-25 03:27:49 +08:00
|
|
|
VariadicConstructor,
|
|
|
|
VariadicDoesNotApply
|
2009-01-17 00:48:51 +08:00
|
|
|
};
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-25 03:27:49 +08:00
|
|
|
/// GatherArgumentsForCall - Collector argument expressions for various
|
|
|
|
/// form of call prototypes.
|
|
|
|
bool GatherArgumentsForCall(SourceLocation CallLoc,
|
|
|
|
FunctionDecl *FDecl,
|
|
|
|
const FunctionProtoType *Proto,
|
|
|
|
unsigned FirstProtoArg,
|
|
|
|
Expr **Args, unsigned NumArgs,
|
|
|
|
llvm::SmallVector<Expr *, 8> &AllArgs,
|
|
|
|
VariadicCallType CallType = VariadicDoesNotApply);
|
|
|
|
|
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-12-16 11:45:30 +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,
|
2009-12-16 11:45:30 +08:00
|
|
|
Expr *SrcExpr, AssignmentAction Action);
|
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
|
|
|
|
2009-12-09 02:24:49 +08:00
|
|
|
AssignConvertType CheckObjCPointerTypesForAssignment(QualType lhsType,
|
|
|
|
QualType rhsType);
|
|
|
|
|
2008-09-04 23:10:53 +08:00
|
|
|
// Helper function for CheckAssignmentConstraints involving two
|
2009-04-20 03:26:31 +08:00
|
|
|
// block pointer types.
|
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-12-16 11:45:30 +08:00
|
|
|
AssignmentAction Action,
|
2009-04-13 01:16:29 +08:00
|
|
|
bool AllowExplicit = false,
|
|
|
|
bool Elidable = false);
|
2009-09-24 04:55:32 +08:00
|
|
|
bool PerformImplicitConversion(Expr *&From, QualType ToType,
|
2009-12-16 11:45:30 +08:00
|
|
|
AssignmentAction Action,
|
2009-09-24 04:55:32 +08:00
|
|
|
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-12-16 11:45:30 +08:00
|
|
|
AssignmentAction Action,
|
2009-11-15 05:15:49 +08:00
|
|
|
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-12-16 11:45:30 +08:00
|
|
|
AssignmentAction Action, bool IgnoreBaseAccess);
|
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
|
2010-01-13 05:23:57 +08:00
|
|
|
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign,
|
|
|
|
bool isDivide);
|
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);
|
2010-02-26 06:29:57 +08:00
|
|
|
QualType FindCompositePointerType(Expr *&E1, Expr *&E2,
|
|
|
|
bool *NonStandardCompositeType = 0);
|
2008-07-15 02:02:46 +08:00
|
|
|
|
2009-12-11 03:47:41 +08:00
|
|
|
QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS,
|
|
|
|
SourceLocation questionLoc);
|
|
|
|
|
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-12-16 14:35:08 +08:00
|
|
|
bool CheckInitList(const InitializedEntity &Entity,
|
|
|
|
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
|
|
|
|
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-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
|
|
|
|
//@{
|
Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for
static_cast<type>(expr)
when we can have an expression, or
using namespace identifier;
when we can have a using directive.
Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.
llvm-svn: 93134
2010-01-11 07:08:15 +08:00
|
|
|
virtual void CodeCompleteOrdinaryName(Scope *S,
|
|
|
|
CodeCompletionContext CompletionContext);
|
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);
|
2010-04-09 00:38:48 +08:00
|
|
|
virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
|
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
|
|
|
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-12-07 17:27:33 +08:00
|
|
|
virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
|
|
|
|
bool InInterface);
|
2010-01-14 05:54:15 +08:00
|
|
|
virtual void CodeCompleteObjCAtVisibility(Scope *S);
|
2009-12-07 17:51:25 +08:00
|
|
|
virtual void CodeCompleteObjCAtStatement(Scope *S);
|
|
|
|
virtual void CodeCompleteObjCAtExpression(Scope *S);
|
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);
|
2010-04-07 08:21:17 +08:00
|
|
|
virtual void CodeCompleteObjCMethodDecl(Scope *S,
|
|
|
|
bool IsInstanceMethod,
|
|
|
|
TypeTy *ReturnType,
|
|
|
|
DeclPtrTy IDecl);
|
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
|
2010-01-29 07:39:18 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
|
|
|
|
unsigned ByteNo) const;
|
|
|
|
|
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-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);
|
2010-02-16 18:07:31 +08:00
|
|
|
bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
|
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);
|
2010-01-05 07:31:57 +08:00
|
|
|
void CheckSignCompare(Expr *LHS, Expr *RHS, SourceLocation Loc,
|
2010-03-12 03:43:18 +08:00
|
|
|
const BinaryOperator::Opcode* BinOpc = 0);
|
2010-01-05 07:31:57 +08:00
|
|
|
void CheckImplicitConversion(Expr *E, QualType Target);
|
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
|