summaryrefslogtreecommitdiffstats
path: root/include/clang/AST
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-08-19 10:33:04 +0000
committerdim <dim@FreeBSD.org>2012-08-19 10:33:04 +0000
commitcc73504950eb7b5dff2dded9bedd67bc36d64641 (patch)
tree5b9c2fa9d79942fbdce3d618e37e27c18263af9a /include/clang/AST
parent554bcb69c2d785a011a30e7db87a36a87fe7db10 (diff)
downloadFreeBSD-src-cc73504950eb7b5dff2dded9bedd67bc36d64641.zip
FreeBSD-src-cc73504950eb7b5dff2dded9bedd67bc36d64641.tar.gz
Vendor import of clang trunk r162107:
http://llvm.org/svn/llvm-project/cfe/trunk@162107
Diffstat (limited to 'include/clang/AST')
-rw-r--r--include/clang/AST/ASTContext.h20
-rw-r--r--include/clang/AST/Attr.h3
-rw-r--r--include/clang/AST/CommentCommandTraits.h6
-rw-r--r--include/clang/AST/DeclBase.h4
-rw-r--r--include/clang/AST/DeclCXX.h13
-rw-r--r--include/clang/AST/DeclGroup.h6
-rw-r--r--include/clang/AST/DeclLookups.h4
-rw-r--r--include/clang/AST/PrettyPrinter.h26
-rw-r--r--include/clang/AST/RawCommentList.h30
-rw-r--r--include/clang/AST/Stmt.h32
-rw-r--r--include/clang/AST/TemplateBase.h20
-rw-r--r--include/clang/AST/TypeLoc.h9
12 files changed, 91 insertions, 82 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 8fd7d6e..cad3ad2 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -474,8 +474,17 @@ public:
Data.setPointer(RC);
}
+ const Decl *getOriginalDecl() const LLVM_READONLY {
+ return OriginalDecl;
+ }
+
+ void setOriginalDecl(const Decl *Orig) {
+ OriginalDecl = Orig;
+ }
+
private:
llvm::PointerIntPair<const RawComment *, 2, Kind> Data;
+ const Decl *OriginalDecl;
};
/// \brief Mapping from declarations to comments attached to any
@@ -485,6 +494,10 @@ public:
/// lazily.
mutable llvm::DenseMap<const Decl *, RawCommentAndCacheFlags> RedeclComments;
+ /// \brief Mapping from declarations to parsed comments attached to any
+ /// redeclaration.
+ mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
+
/// \brief Return the documentation comment attached to a given declaration,
/// without looking into cache.
RawComment *getRawCommentForDeclNoCache(const Decl *D) const;
@@ -500,7 +513,12 @@ public:
/// \brief Return the documentation comment attached to a given declaration.
/// Returns NULL if no comment is attached.
- const RawComment *getRawCommentForAnyRedecl(const Decl *D) const;
+ ///
+ /// \param OriginalDecl if not NULL, is set to declaration AST node that had
+ /// the comment, if the comment we found comes from a redeclaration.
+ const RawComment *getRawCommentForAnyRedecl(
+ const Decl *D,
+ const Decl **OriginalDecl = NULL) const;
/// Return parsed documentation comment attached to a given declaration.
/// Returns NULL if no comment is attached.
diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h
index 27b44d4..b17bd48 100644
--- a/include/clang/AST/Attr.h
+++ b/include/clang/AST/Attr.h
@@ -105,7 +105,8 @@ public:
virtual bool isLateParsed() const { return false; }
// Pretty print this attribute.
- virtual void printPretty(llvm::raw_ostream &OS, ASTContext &C) const = 0;
+ virtual void printPretty(llvm::raw_ostream &OS,
+ const PrintingPolicy &Policy) const = 0;
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *) { return true; }
diff --git a/include/clang/AST/CommentCommandTraits.h b/include/clang/AST/CommentCommandTraits.h
index f188375..5f0269a 100644
--- a/include/clang/AST/CommentCommandTraits.h
+++ b/include/clang/AST/CommentCommandTraits.h
@@ -35,14 +35,14 @@ public:
/// A verbatim-like block command eats every character (except line starting
/// decorations) until matching end command is seen or comment end is hit.
///
- /// \param BeginName name of the command that starts the verbatim block.
+ /// \param StartName name of the command that starts the verbatim block.
/// \param [out] EndName name of the command that ends the verbatim block.
///
/// \returns true if a given command is a verbatim block command.
bool isVerbatimBlockCommand(StringRef StartName, StringRef &EndName) const;
/// \brief Register a new verbatim block command.
- void addVerbatimBlockCommand(StringRef BeginName, StringRef EndName);
+ void addVerbatimBlockCommand(StringRef StartName, StringRef EndName);
/// \brief Check if a given command is a verbatim line command.
///
@@ -90,7 +90,7 @@ public:
private:
struct VerbatimBlockCommand {
- StringRef BeginName;
+ StringRef StartName;
StringRef EndName;
};
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index ac2cc9e..0f59609 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -858,10 +858,10 @@ public:
raw_ostream &Out, const PrintingPolicy &Policy,
unsigned Indentation = 0);
// Debuggers don't usually respect default arguments.
- LLVM_ATTRIBUTE_USED void dump() const { dump(llvm::errs()); }
+ LLVM_ATTRIBUTE_USED void dump() const;
void dump(raw_ostream &Out) const;
// Debuggers don't usually respect default arguments.
- LLVM_ATTRIBUTE_USED void dumpXML() const { dumpXML(llvm::errs()); }
+ LLVM_ATTRIBUTE_USED void dumpXML() const;
void dumpXML(raw_ostream &OS) const;
private:
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 851e310..2d95f03 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -1646,14 +1646,17 @@ public:
/// \brief Find the method in RD that corresponds to this one.
///
/// Find if RD or one of the classes it inherits from override this method.
- /// If so, return it. RD is assumed to be a base class of the class defining
- /// this method (or be the class itself).
+ /// If so, return it. RD is assumed to be a subclass of the class defining
+ /// this method (or be the class itself), unless MayBeBase is set to true.
CXXMethodDecl *
- getCorrespondingMethodInClass(const CXXRecordDecl *RD);
+ getCorrespondingMethodInClass(const CXXRecordDecl *RD,
+ bool MayBeBase = false);
const CXXMethodDecl *
- getCorrespondingMethodInClass(const CXXRecordDecl *RD) const {
- return const_cast<CXXMethodDecl*>(this)->getCorrespondingMethodInClass(RD);
+ getCorrespondingMethodInClass(const CXXRecordDecl *RD,
+ bool MayBeBase = false) const {
+ return const_cast<CXXMethodDecl *>(this)
+ ->getCorrespondingMethodInClass(RD, MayBeBase);
}
// Implement isa/cast/dyncast/etc.
diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h
index 63cdac5..cda6ae5 100644
--- a/include/clang/AST/DeclGroup.h
+++ b/include/clang/AST/DeclGroup.h
@@ -26,7 +26,11 @@ class DeclGroupIterator;
class DeclGroup {
// FIXME: Include a TypeSpecifier object.
- unsigned NumDecls;
+ union {
+ unsigned NumDecls;
+
+ Decl *Aligner;
+ };
private:
DeclGroup() : NumDecls(0) {}
diff --git a/include/clang/AST/DeclLookups.h b/include/clang/AST/DeclLookups.h
index b8abe97..867b465 100644
--- a/include/clang/AST/DeclLookups.h
+++ b/include/clang/AST/DeclLookups.h
@@ -67,7 +67,7 @@ public:
DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
DeclContext *Primary = const_cast<DeclContext*>(this)->getPrimaryContext();
- if (hasExternalVisibleStorage())
+ if (Primary->hasExternalVisibleStorage())
getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary);
if (StoredDeclsMap *Map = Primary->buildLookup())
return all_lookups_iterator(Map->begin(), Map->end());
@@ -76,7 +76,7 @@ DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
DeclContext::all_lookups_iterator DeclContext::lookups_end() const {
DeclContext *Primary = const_cast<DeclContext*>(this)->getPrimaryContext();
- if (hasExternalVisibleStorage())
+ if (Primary->hasExternalVisibleStorage())
getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary);
if (StoredDeclsMap *Map = Primary->buildLookup())
return all_lookups_iterator(Map->end(), Map->end());
diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h
index 2e34dc8..f2c015f 100644
--- a/include/clang/AST/PrettyPrinter.h
+++ b/include/clang/AST/PrettyPrinter.h
@@ -34,19 +34,19 @@ public:
struct PrintingPolicy {
/// \brief Create a default printing policy for C.
PrintingPolicy(const LangOptions &LO)
- : Indentation(2), LangOpts(LO), SuppressSpecifiers(false),
+ : LangOpts(LO), Indentation(2), SuppressSpecifiers(false),
SuppressTagKeyword(false), SuppressTag(false), SuppressScope(false),
SuppressUnwrittenScope(false), SuppressInitializers(false),
- Dump(false), ConstantArraySizeAsWritten(false),
- AnonymousTagLocations(true), SuppressStrongLifetime(false),
- Bool(LO.Bool) { }
-
- /// \brief The number of spaces to use to indent each line.
- unsigned Indentation : 8;
+ ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
+ SuppressStrongLifetime(false), Bool(LO.Bool),
+ DumpSourceManager(0) { }
/// \brief What language we're printing.
LangOptions LangOpts;
+ /// \brief The number of spaces to use to indent each line.
+ unsigned Indentation : 8;
+
/// \brief Whether we should suppress printing of the actual specifiers for
/// the given type or declaration.
///
@@ -103,12 +103,6 @@ struct PrintingPolicy {
/// internal initializer constructed for x will not be printed.
bool SuppressInitializers : 1;
- /// \brief True when we are "dumping" rather than "pretty-printing",
- /// where dumping involves printing the internal details of the AST
- /// and pretty-printing involves printing something similar to
- /// source code.
- bool Dump : 1;
-
/// \brief Whether we should print the sizes of constant array expressions
/// as written in the sources.
///
@@ -139,6 +133,12 @@ struct PrintingPolicy {
/// \brief Whether we can use 'bool' rather than '_Bool', even if the language
/// doesn't actually have 'bool' (because, e.g., it is defined as a macro).
unsigned Bool : 1;
+
+ /// \brief If we are "dumping" rather than "pretty-printing", this points to
+ /// a SourceManager which will be used to dump SourceLocations. Dumping
+ /// involves printing the internal details of the AST and pretty-printing
+ /// involves printing something similar to source code.
+ SourceManager *DumpSourceManager;
};
} // end namespace clang
diff --git a/include/clang/AST/RawCommentList.h b/include/clang/AST/RawCommentList.h
index 4901d07..630626b 100644
--- a/include/clang/AST/RawCommentList.h
+++ b/include/clang/AST/RawCommentList.h
@@ -55,16 +55,11 @@ public:
/// Is this comment attached to any declaration?
bool isAttached() const LLVM_READONLY {
- return !DeclOrParsedComment.isNull();
+ return IsAttached;
}
- /// Return the declaration that this comment is attached to.
- const Decl *getDecl() const;
-
- /// Set the declaration that this comment is attached to.
- void setDecl(const Decl *D) {
- assert(DeclOrParsedComment.isNull());
- DeclOrParsedComment = D;
+ void setAttached() {
+ IsAttached = true;
}
/// Returns true if it is a comment that should be put after a member:
@@ -118,28 +113,23 @@ public:
return extractBriefText(Context);
}
- /// Returns a \c FullComment AST node, parsing the comment if needed.
- comments::FullComment *getParsed(const ASTContext &Context) const {
- if (comments::FullComment *FC =
- DeclOrParsedComment.dyn_cast<comments::FullComment *>())
- return FC;
-
- return parse(Context);
- }
+ /// Parse the comment, assuming it is attached to decl \c D.
+ comments::FullComment *parse(const ASTContext &Context, const Decl *D) const;
private:
SourceRange Range;
mutable StringRef RawText;
mutable const char *BriefText;
- mutable llvm::PointerUnion<const Decl *, comments::FullComment *>
- DeclOrParsedComment;
mutable bool RawTextValid : 1; ///< True if RawText is valid
mutable bool BriefTextValid : 1; ///< True if BriefText is valid
unsigned Kind : 3;
+ /// True if comment is attached to a declaration in ASTContext.
+ bool IsAttached : 1;
+
bool IsTrailingComment : 1;
bool IsAlmostTrailingComment : 1;
@@ -152,7 +142,7 @@ private:
RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
bool IsAlmostTrailingComment) :
Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
- IsTrailingComment(IsTrailingComment),
+ IsAttached(false), IsTrailingComment(IsTrailingComment),
IsAlmostTrailingComment(IsAlmostTrailingComment),
BeginLineValid(false), EndLineValid(false)
{ }
@@ -161,8 +151,6 @@ private:
const char *extractBriefText(const ASTContext &Context) const;
- comments::FullComment *parse(const ASTContext &Context) const;
-
friend class ASTReader;
};
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 79e1920..35fb693 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -373,15 +373,9 @@ public:
/// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
/// back to its original source language syntax.
- void dumpPretty(ASTContext& Context) const;
+ void dumpPretty(ASTContext &Context) const;
void printPretty(raw_ostream &OS, PrinterHelper *Helper,
const PrintingPolicy &Policy,
- unsigned Indentation = 0) const {
- printPretty(OS, *(ASTContext*)0, Helper, Policy, Indentation);
- }
- void printPretty(raw_ostream &OS, ASTContext &Context,
- PrinterHelper *Helper,
- const PrintingPolicy &Policy,
unsigned Indentation = 0) const;
/// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
@@ -1620,36 +1614,40 @@ public:
/// MSAsmStmt - This represents a MS inline-assembly statement extension.
///
class MSAsmStmt : public Stmt {
- SourceLocation AsmLoc, EndLoc;
+ SourceLocation AsmLoc, LBraceLoc, EndLoc;
std::string AsmStr;
bool IsSimple;
bool IsVolatile;
unsigned NumAsmToks;
- unsigned NumLineEnds;
+ unsigned NumInputs;
+ unsigned NumOutputs;
unsigned NumClobbers;
Token *AsmToks;
- unsigned *LineEnds;
+ IdentifierInfo **Names;
Stmt **Exprs;
StringRef *Clobbers;
public:
- MSAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
- bool isvolatile, ArrayRef<Token> asmtoks,
- ArrayRef<unsigned> lineends, StringRef asmstr,
- ArrayRef<StringRef> clobbers, SourceLocation endloc);
+ MSAsmStmt(ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc,
+ bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
+ ArrayRef<IdentifierInfo*> inputs, ArrayRef<IdentifierInfo*> outputs,
+ StringRef asmstr, ArrayRef<StringRef> clobbers,
+ SourceLocation endloc);
SourceLocation getAsmLoc() const { return AsmLoc; }
void setAsmLoc(SourceLocation L) { AsmLoc = L; }
+ SourceLocation getLBraceLoc() const { return LBraceLoc; }
+ void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
SourceLocation getEndLoc() const { return EndLoc; }
void setEndLoc(SourceLocation L) { EndLoc = L; }
+ bool hasBraces() const { return LBraceLoc.isValid(); }
+
unsigned getNumAsmToks() { return NumAsmToks; }
Token *getAsmToks() { return AsmToks; }
- unsigned getNumLineEnds() { return NumLineEnds; }
- unsigned *getLineEnds() { return LineEnds; }
bool isVolatile() const { return IsVolatile; }
void setVolatile(bool V) { IsVolatile = V; }
@@ -1665,7 +1663,7 @@ public:
//===--- Other ---===//
unsigned getNumClobbers() const { return NumClobbers; }
- StringRef getClobber(unsigned i) { return Clobbers[i]; }
+ StringRef getClobber(unsigned i) const { return Clobbers[i]; }
SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AsmLoc, EndLoc);
diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h
index 54c9f2c..5047028 100644
--- a/include/clang/AST/TemplateBase.h
+++ b/include/clang/AST/TemplateBase.h
@@ -510,17 +510,23 @@ public:
/// This is safe to be used inside an AST node, in contrast with
/// TemplateArgumentListInfo.
struct ASTTemplateArgumentListInfo {
- /// \brief The source location of the left angle bracket ('<');
+ /// \brief The source location of the left angle bracket ('<').
SourceLocation LAngleLoc;
- /// \brief The source location of the right angle bracket ('>');
+ /// \brief The source location of the right angle bracket ('>').
SourceLocation RAngleLoc;
- /// \brief The number of template arguments in TemplateArgs.
- /// The actual template arguments (if any) are stored after the
- /// ExplicitTemplateArgumentList structure.
- unsigned NumTemplateArgs;
-
+ union {
+ /// \brief The number of template arguments in TemplateArgs.
+ /// The actual template arguments (if any) are stored after the
+ /// ExplicitTemplateArgumentList structure.
+ unsigned NumTemplateArgs;
+
+ /// Force ASTTemplateArgumentListInfo to the right alignment
+ /// for the following array of TemplateArgumentLocs.
+ void *Aligner;
+ };
+
/// \brief Retrieve the template arguments
TemplateArgumentLoc *getTemplateArgs() {
return reinterpret_cast<TemplateArgumentLoc *> (this + 1);
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index 1d1c1d1..11a878d 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -1061,7 +1061,6 @@ public:
struct FunctionLocInfo {
SourceLocation LocalRangeBegin;
SourceLocation LocalRangeEnd;
- bool TrailingReturn;
};
/// \brief Wrapper for source info for functions.
@@ -1084,13 +1083,6 @@ public:
getLocalData()->LocalRangeEnd = L;
}
- bool getTrailingReturn() const {
- return getLocalData()->TrailingReturn;
- }
- void setTrailingReturn(bool Trailing) {
- getLocalData()->TrailingReturn = Trailing;
- }
-
ArrayRef<ParmVarDecl *> getParams() const {
return ArrayRef<ParmVarDecl *>(getParmArray(), getNumArgs());
}
@@ -1119,7 +1111,6 @@ public:
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
setLocalRangeBegin(Loc);
setLocalRangeEnd(Loc);
- setTrailingReturn(false);
for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
setArg(i, NULL);
}
OpenPOWER on IntegriCloud