Skip to content

Commit 2fb1376

Browse files
committed
Add an option and checking for generation of deprecated declarations.
1 parent fe5e72b commit 2fb1376

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/CppParser/AST.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Declaration::Declaration(const Declaration& rhs)
272272
, isDependent(rhs.isDependent)
273273
, isImplicit(rhs.isImplicit)
274274
, isInvalid(rhs.isInvalid)
275-
, isDeprecated(false)
275+
, isDeprecated(rhs.isDeprecated)
276276
, completeDeclaration(rhs.completeDeclaration)
277277
, definitionOrder(rhs.definitionOrder)
278278
, PreprocessedEntities(rhs.PreprocessedEntities)

src/Generator/Options.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ public bool DoAllModulesHaveLibraries() =>
144144
/// </summary>
145145
public bool GenerateDefaultValuesForArguments { get; set; }
146146

147+
/// <summary>
148+
/// If set to false, then deprecated C/C++ declarations (those that have
149+
/// the `__attribute__((deprecated))` or equivalent attribute) will not be
150+
/// generated.
151+
/// </summary>
152+
public bool GenerateDeprecatedDeclarations { get; set; } = true;
153+
147154
public bool StripLibPrefix { get; set; }
148155

149156
/// <summary>

src/Generator/Passes/CheckIgnoredDecls.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ public override bool VisitDeclaration(Declaration decl)
8585
return true;
8686
}
8787

88+
if (decl.IsDeprecated && !Options.GenerateDeprecatedDeclarations)
89+
{
90+
Diagnostics.Debug("Decl '{0}' was ignored due to being deprecated", decl.Name);
91+
decl.ExplicitlyIgnore();
92+
return true;
93+
}
94+
8895
if (!CheckDeclarationAccess(decl))
8996
{
9097
Diagnostics.Debug("Decl '{0}' was ignored due to invalid access",

0 commit comments

Comments
 (0)