diff --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h index 8cb370e6f833..1580d1b693d8 100644 --- a/clang/include/clang/Lex/MacroInfo.h +++ b/clang/include/clang/Lex/MacroInfo.h @@ -21,7 +21,7 @@ #include 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(this)->getPreviousDefinition(AllowHidden); + inline DefInfo getPreviousDefinition(); + const DefInfo getPreviousDefinition() const { + return const_cast(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(this)->getDefinition(AllowHidden); + DefInfo getDefinition(); + const DefInfo getDefinition() const { + return const_cast(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 diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp index b61ff71d1767..a7b55156c5d7 100644 --- a/clang/lib/Lex/MacroInfo.cpp +++ b/clang/lib/Lex/MacroInfo.cpp @@ -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 isPublic; for (; MD; MD = MD->getPrevious()) { - if (!AllowHidden && MD->isHidden()) - continue; - if (DefMacroDirective *DefMD = dyn_cast(MD)) return DefInfo(DefMD, UndefLoc, !isPublic.hasValue() || isPublic.getValue()); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index cb059ecc4e3e..e931a7eeb2ae 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -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 isPublic; for (; MD; MD = MD->getPrevious()) { - if (MD->isHidden()) - continue; - SubmoduleID ThisModID = getSubmoduleID(MD); if (ThisModID == 0) { isUndefined = false;