jdenny created this revision.
jdenny added a reviewer: rsmith.
And make it have no effect. Suggested at:
https://reviews.llvm.org/D45463#1096629
I'm not sure of the proper way to deprecate something in libclang.
Let me know if something else is needed.
https://reviews.llvm.org/D46919
Files:
include/clang-c/Index.h
include/clang/AST/PrettyPrinter.h
lib/AST/DeclPrinter.cpp
lib/AST/TypePrinter.cpp
Index: lib/AST/TypePrinter.cpp
===================================================================
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -454,7 +454,7 @@
OS << '(';
PrintingPolicy InnerPolicy(Policy);
- InnerPolicy.IncludeTagDefinition = false;
+ InnerPolicy.PrintOwnedTagDecl = false;
TypePrinter(InnerPolicy).print(QualType(T->getClass(), 0), OS, StringRef());
OS << "::*";
@@ -1054,9 +1054,9 @@
}
void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) {
- if (Policy.IncludeTagDefinition) {
+ if (Policy.PrintOwnedTagDecl) {
PrintingPolicy SubPolicy = Policy;
- SubPolicy.IncludeTagDefinition = false;
+ SubPolicy.PrintOwnedTagDecl = false;
D->print(OS, SubPolicy, Indentation);
spaceBeforePlaceHolder(OS);
return;
@@ -1209,35 +1209,34 @@
void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
raw_ostream &OS) {
- if (Policy.IncludeTagDefinition && T->getOwnedTagDecl()) {
+ if (Policy.PrintOwnedTagDecl && T->getOwnedTagDecl()) {
TagDecl *OwnedTagDecl = T->getOwnedTagDecl();
assert(OwnedTagDecl->getTypeForDecl() == T->getNamedType().getTypePtr() &&
"OwnedTagDecl expected to be a declaration for the type");
PrintingPolicy SubPolicy = Policy;
- SubPolicy.IncludeTagDefinition = false;
+ SubPolicy.PrintOwnedTagDecl = false;
OwnedTagDecl->print(OS, SubPolicy, Indentation);
spaceBeforePlaceHolder(OS);
return;
}
// The tag definition will take care of these.
- if (!Policy.IncludeTagDefinition)
- {
+ if (!Policy.PrintOwnedTagDecl) {
OS << TypeWithKeyword::getKeywordName(T->getKeyword());
if (T->getKeyword() != ETK_None)
OS << " ";
NestedNameSpecifier *Qualifier = T->getQualifier();
if (Qualifier)
Qualifier->print(OS, Policy);
}
-
+
ElaboratedTypePolicyRAII PolicyRAII(Policy);
printBefore(T->getNamedType(), OS);
}
void TypePrinter::printElaboratedAfter(const ElaboratedType *T,
raw_ostream &OS) {
- if (Policy.IncludeTagDefinition && T->getOwnedTagDecl())
+ if (Policy.PrintOwnedTagDecl && T->getOwnedTagDecl())
return;
ElaboratedTypePolicyRAII PolicyRAII(Policy);
printAfter(T->getNamedType(), OS);
Index: lib/AST/DeclPrinter.cpp
===================================================================
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -178,12 +178,12 @@
for ( ; Begin != End; ++Begin) {
if (isFirst) {
if(TD)
- SubPolicy.IncludeTagDefinition = true;
+ SubPolicy.PrintOwnedTagDecl = true;
SubPolicy.SuppressSpecifiers = false;
isFirst = false;
} else {
if (!isFirst) Out << ", ";
- SubPolicy.IncludeTagDefinition = false;
+ SubPolicy.PrintOwnedTagDecl = false;
SubPolicy.SuppressSpecifiers = true;
}
@@ -849,7 +849,7 @@
}
PrintingPolicy SubPolicy(Policy);
SubPolicy.SuppressSpecifiers = false;
- SubPolicy.IncludeTagDefinition = false;
+ SubPolicy.PrintOwnedTagDecl = false;
Init->printPretty(Out, nullptr, SubPolicy, Indentation);
if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
Out << ")";
Index: include/clang/AST/PrettyPrinter.h
===================================================================
--- include/clang/AST/PrettyPrinter.h
+++ include/clang/AST/PrettyPrinter.h
@@ -40,7 +40,8 @@
PrintingPolicy(const LangOptions &LO)
: Indentation(2), SuppressSpecifiers(false),
SuppressTagKeyword(LO.CPlusPlus),
- IncludeTagDefinition(false), SuppressScope(false),
+ IncludeTagDefinition(false), PrintOwnedTagDecl(false),
+ SuppressScope(false),
SuppressUnwrittenScope(false), SuppressInitializers(false),
ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
@@ -93,15 +94,18 @@
/// \endcode
bool SuppressTagKeyword : 1;
- /// When true, include the body of a tag definition.
+ /// This flag is deprecated and no longer has any effect.
+ bool IncludeTagDefinition : 1;
+
+ /// When true, print any tag declaration owned by an elaborated type.
///
- /// This is used to place the definition of a struct
- /// in the middle of another declaration as with:
+ /// This is used to faithfully print the exact tag declaration that appears
+ /// within another declaration. For example:
///
/// \code
- /// typedef struct { int x, y; } Point;
+ /// typedef struct T { int x, y; } Point;
/// \endcode
- bool IncludeTagDefinition : 1;
+ bool PrintOwnedTagDecl : 1;
/// Suppresses printing of scope specifiers.
bool SuppressScope : 1;
Index: include/clang-c/Index.h
===================================================================
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -4115,7 +4115,7 @@
CXPrintingPolicy_Indentation,
CXPrintingPolicy_SuppressSpecifiers,
CXPrintingPolicy_SuppressTagKeyword,
- CXPrintingPolicy_IncludeTagDefinition,
+ CXPrintingPolicy_IncludeTagDefinition, ///< deprecated and has no effect
CXPrintingPolicy_SuppressScope,
CXPrintingPolicy_SuppressUnwrittenScope,
CXPrintingPolicy_SuppressInitializers,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits