Remove dead code; MacroDirective's IsHidden flag is always false.

llvm-svn: 200265
This commit is contained in:
Richard Smith 2014-01-27 23:54:39 +00:00
parent f07ee3ae28
commit 2e87e14490
3 changed files with 18 additions and 38 deletions

View File

@ -21,7 +21,7 @@
#include <cassert>
namespace clang {
class Preprocessor;
class Preprocessor;
/// \brief Encapsulates the data about a macro definition (e.g. its tokens).
///
@ -338,12 +338,6 @@ protected:
/// \brief True if the macro directive was loaded from a PCH file.
bool IsFromPCH : 1;
/// \brief Whether the macro directive is currently "hidden".
///
/// Note that this is transient state that is never serialized to the AST
/// file.
bool IsHidden : 1;
// Used by DefMacroDirective -----------------------------------------------//
/// \brief True if this macro was imported from a module.
@ -360,10 +354,10 @@ protected:
bool IsPublic : 1;
MacroDirective(Kind K, SourceLocation Loc)
: Previous(0), Loc(Loc), MDKind(K), IsFromPCH(false), IsHidden(false),
: Previous(0), Loc(Loc), MDKind(K), IsFromPCH(false),
IsImported(false), IsAmbiguous(false),
IsPublic(true) {
}
}
public:
Kind getKind() const { return Kind(MDKind); }
@ -386,12 +380,6 @@ public:
void setIsFromPCH() { IsFromPCH = true; }
/// \brief Determine whether this macro directive is hidden.
bool isHidden() const { return IsHidden; }
/// \brief Set whether this macro directive is hidden.
void setHidden(bool Val) { IsHidden = Val; }
class DefInfo {
DefMacroDirective *DefDirective;
SourceLocation UndefLoc;
@ -423,31 +411,31 @@ public:
LLVM_EXPLICIT operator bool() const { return isValid(); }
inline DefInfo getPreviousDefinition(bool AllowHidden = false);
const DefInfo getPreviousDefinition(bool AllowHidden = false) const {
return const_cast<DefInfo*>(this)->getPreviousDefinition(AllowHidden);
inline DefInfo getPreviousDefinition();
const DefInfo getPreviousDefinition() const {
return const_cast<DefInfo*>(this)->getPreviousDefinition();
}
};
/// \brief Traverses the macro directives history and returns the next
/// macro definition directive along with info about its undefined location
/// (if there is one) and if it is public or private.
DefInfo getDefinition(bool AllowHidden = false);
const DefInfo getDefinition(bool AllowHidden = false) const {
return const_cast<MacroDirective*>(this)->getDefinition(AllowHidden);
DefInfo getDefinition();
const DefInfo getDefinition() const {
return const_cast<MacroDirective*>(this)->getDefinition();
}
bool isDefined(bool AllowHidden = false) const {
if (const DefInfo Def = getDefinition(AllowHidden))
bool isDefined() const {
if (const DefInfo Def = getDefinition())
return !Def.isUndefined();
return false;
}
const MacroInfo *getMacroInfo(bool AllowHidden = false) const {
return getDefinition(AllowHidden).getMacroInfo();
const MacroInfo *getMacroInfo() const {
return getDefinition().getMacroInfo();
}
MacroInfo *getMacroInfo(bool AllowHidden = false) {
return getDefinition(AllowHidden).getMacroInfo();
MacroInfo *getMacroInfo() {
return getDefinition().getMacroInfo();
}
/// \brief Find macro definition active in the specified source location. If
@ -538,10 +526,10 @@ inline MacroInfo *MacroDirective::DefInfo::getMacroInfo() {
}
inline MacroDirective::DefInfo
MacroDirective::DefInfo::getPreviousDefinition(bool AllowHidden) {
MacroDirective::DefInfo::getPreviousDefinition() {
if (isInvalid() || DefDirective->getPrevious() == 0)
return DefInfo();
return DefDirective->getPrevious()->getDefinition(AllowHidden);
return DefDirective->getPrevious()->getDefinition();
}
} // end namespace clang

View File

@ -125,14 +125,11 @@ bool MacroInfo::isIdenticalTo(const MacroInfo &Other, Preprocessor &PP,
return true;
}
MacroDirective::DefInfo MacroDirective::getDefinition(bool AllowHidden) {
MacroDirective::DefInfo MacroDirective::getDefinition() {
MacroDirective *MD = this;
SourceLocation UndefLoc;
Optional<bool> isPublic;
for (; MD; MD = MD->getPrevious()) {
if (!AllowHidden && MD->isHidden())
continue;
if (DefMacroDirective *DefMD = dyn_cast<DefMacroDirective>(MD))
return DefInfo(DefMD, UndefLoc,
!isPublic.hasValue() || isPublic.getValue());

View File

@ -1951,8 +1951,6 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
// Emit the macro directives in reverse source order.
for (; MD; MD = MD->getPrevious()) {
if (MD->isHidden())
continue;
if (shouldIgnoreMacro(MD, IsModule, PP))
continue;
@ -2995,9 +2993,6 @@ class ASTIdentifierTableTrait {
bool isUndefined = false;
Optional<bool> isPublic;
for (; MD; MD = MD->getPrevious()) {
if (MD->isHidden())
continue;
SubmoduleID ThisModID = getSubmoduleID(MD);
if (ThisModID == 0) {
isUndefined = false;