namespace clang {
class Decl;
-class MacroDefinition;
+class MacroDefinitionRecord;
class SourceManager;
namespace index {
/// \brief Generate a USR for a macro, including the USR prefix.
///
/// \returns true on error, false on success.
-bool generateUSRForMacro(const MacroDefinition *MD, const SourceManager &SM,
- SmallVectorImpl<char> &Buf);
+bool generateUSRForMacro(const MacroDefinitionRecord *MD,
+ const SourceManager &SM, SmallVectorImpl<char> &Buf);
} // namespace index
} // namespace clang
#include "clang/Lex/Token.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Allocator.h"
#include <cassert>
/// Get the number of macros that override this one.
unsigned getNumOverridingMacros() const { return NumOverriddenBy; }
+};
+
+/// \brief A description of the current definition of a macro.
+///
+/// The definition of a macro comprises a set of (at least one) defining
+/// entities, which are either local MacroDirectives or imported ModuleMacros.
+class MacroDefinition {
+ llvm::PointerIntPair<DefMacroDirective *, 1, bool> LatestLocalAndAmbiguous;
+ ArrayRef<ModuleMacro *> ModuleMacros;
+
+public:
+ MacroDefinition() : LatestLocalAndAmbiguous(), ModuleMacros() {}
+ MacroDefinition(DefMacroDirective *MD, ArrayRef<ModuleMacro *> MMs,
+ bool IsAmbiguous)
+ : LatestLocalAndAmbiguous(MD, IsAmbiguous), ModuleMacros(MMs) {}
+
+ /// \brief Determine whether there is a definition of this macro.
+ explicit operator bool() const {
+ return getLocalDirective() || !ModuleMacros.empty();
+ }
+
+ /// \brief Get the MacroInfo that should be used for this definition.
+ MacroInfo *getMacroInfo() const {
+ if (!ModuleMacros.empty())
+ return ModuleMacros.back()->getMacroInfo();
+ if (auto *MD = getLocalDirective())
+ return MD->getMacroInfo();
+ return nullptr;
+ }
+
+ /// \brief \c true if the definition is ambiguous, \c false otherwise.
+ bool isAmbiguous() const { return LatestLocalAndAmbiguous.getInt(); }
+
+ /// \brief Get the latest non-imported, non-\#undef'd macro definition
+ /// for this macro.
+ DefMacroDirective *getLocalDirective() const {
+ return LatestLocalAndAmbiguous.getPointer();
+ }
+
+ /// \brief Get the active module macros for this macro.
+ ArrayRef<ModuleMacro *> getModuleMacros() const { return ModuleMacros; }
+ template <typename Fn> void forAllDefinitions(Fn F) const {
+ if (auto *MD = getLocalDirective())
+ F(MD->getMacroInfo());
+ for (auto *MM : getModuleMacros())
+ F(MM->getMacroInfo());
+ }
};
-} // end namespace clang
+} // end namespace clang
#endif
unsigned alignment = 8) throw();
/// \brief Frees memory allocated in a Clang preprocessing record.
-void operator delete(void* ptr, clang::PreprocessingRecord& PR,
+void operator delete(void *ptr, clang::PreprocessingRecord &PR,
unsigned) throw();
namespace clang {
- class MacroDefinition;
+ class MacroDefinitionRecord;
class FileEntry;
/// \brief Base class that describes a preprocessed entity, which may be a
PD->getKind() <= LastPreprocessingDirective;
}
};
-
+
/// \brief Record the location of a macro definition.
- class MacroDefinition : public PreprocessingDirective {
+ class MacroDefinitionRecord : public PreprocessingDirective {
/// \brief The name of the macro being defined.
const IdentifierInfo *Name;
public:
- explicit MacroDefinition(const IdentifierInfo *Name, SourceRange Range)
- : PreprocessingDirective(MacroDefinitionKind, Range), Name(Name) { }
-
+ explicit MacroDefinitionRecord(const IdentifierInfo *Name,
+ SourceRange Range)
+ : PreprocessingDirective(MacroDefinitionKind, Range), Name(Name) {}
+
/// \brief Retrieve the name of the macro being defined.
const IdentifierInfo *getName() const { return Name; }
-
+
/// \brief Retrieve the location of the macro name in the definition.
SourceLocation getLocation() const { return getSourceRange().getBegin(); }
class MacroExpansion : public PreprocessedEntity {
/// \brief The definition of this macro or the name of the macro if it is
/// a builtin macro.
- llvm::PointerUnion<IdentifierInfo *, MacroDefinition *> NameOrDef;
+ llvm::PointerUnion<IdentifierInfo *, MacroDefinitionRecord *> NameOrDef;
public:
MacroExpansion(IdentifierInfo *BuiltinName, SourceRange Range)
- : PreprocessedEntity(MacroExpansionKind, Range),
- NameOrDef(BuiltinName) { }
+ : PreprocessedEntity(MacroExpansionKind, Range),
+ NameOrDef(BuiltinName) {}
- MacroExpansion(MacroDefinition *Definition, SourceRange Range)
- : PreprocessedEntity(MacroExpansionKind, Range),
- NameOrDef(Definition) { }
+ MacroExpansion(MacroDefinitionRecord *Definition, SourceRange Range)
+ : PreprocessedEntity(MacroExpansionKind, Range), NameOrDef(Definition) {
+ }
/// \brief True if it is a builtin macro.
bool isBuiltinMacro() const { return NameOrDef.is<IdentifierInfo *>(); }
-
+
/// \brief The name of the macro being expanded.
const IdentifierInfo *getName() const {
- if (MacroDefinition *Def = getDefinition())
+ if (MacroDefinitionRecord *Def = getDefinition())
return Def->getName();
- return NameOrDef.get<IdentifierInfo*>();
+ return NameOrDef.get<IdentifierInfo *>();
}
-
+
/// \brief The definition of the macro being expanded. May return null if
/// this is a builtin macro.
- MacroDefinition *getDefinition() const {
- return NameOrDef.dyn_cast<MacroDefinition *>();
+ MacroDefinitionRecord *getDefinition() const {
+ return NameOrDef.dyn_cast<MacroDefinitionRecord *>();
}
// Implement isa/cast/dyncast/etc.
}
/// \brief Mapping from MacroInfo structures to their definitions.
- llvm::DenseMap<const MacroInfo *, MacroDefinition *> MacroDefinitions;
+ llvm::DenseMap<const MacroInfo *, MacroDefinitionRecord *> MacroDefinitions;
/// \brief External source of preprocessed entities.
ExternalPreprocessingRecordSource *ExternalSource;
unsigned allocateLoadedEntities(unsigned NumEntities);
/// \brief Register a new macro definition.
- void RegisterMacroDefinition(MacroInfo *Macro, MacroDefinition *Def);
-
+ void RegisterMacroDefinition(MacroInfo *Macro, MacroDefinitionRecord *Def);
+
public:
/// \brief Construct a new preprocessing record.
explicit PreprocessingRecord(SourceManager &SM);
-
+
/// \brief Allocate memory in the preprocessing record.
void *Allocate(unsigned Size, unsigned Align = 8) {
return BumpAlloc.Allocate(Size, Align);
ExternalPreprocessingRecordSource *getExternalSource() const {
return ExternalSource;
}
-
+
/// \brief Retrieve the macro definition that corresponds to the given
/// \c MacroInfo.
- MacroDefinition *findMacroDefinition(const MacroInfo *MI);
+ MacroDefinitionRecord *findMacroDefinition(const MacroInfo *MI);
/// \brief Retrieve all ranges that got skipped while preprocessing.
const std::vector<SourceRange> &getSkippedRanges() const {
}
/// \}
- /// \brief A description of the current definition of a macro.
- class MacroDefinition {
- llvm::PointerIntPair<DefMacroDirective*, 1, bool> LatestLocalAndAmbiguous;
- ArrayRef<ModuleMacro*> ModuleMacros;
- public:
- MacroDefinition() : LatestLocalAndAmbiguous(), ModuleMacros() {}
- MacroDefinition(DefMacroDirective *MD, ArrayRef<ModuleMacro *> MMs,
- bool IsAmbiguous)
- : LatestLocalAndAmbiguous(MD, IsAmbiguous), ModuleMacros(MMs) {}
-
- /// \brief Determine whether there is a definition of this macro.
- explicit operator bool() const {
- return getLocalDirective() || !ModuleMacros.empty();
- }
-
- /// \brief Get the MacroInfo that should be used for this definition.
- MacroInfo *getMacroInfo() const {
- if (!ModuleMacros.empty())
- return ModuleMacros.back()->getMacroInfo();
- if (auto *MD = getLocalDirective())
- return MD->getMacroInfo();
- return nullptr;
- }
-
- /// \brief \c true if the definition is ambiguous, \c false otherwise.
- bool isAmbiguous() const { return LatestLocalAndAmbiguous.getInt(); }
-
- /// \brief Get the latest non-imported, non-\#undef'd macro definition
- /// for this macro.
- DefMacroDirective *getLocalDirective() const {
- return LatestLocalAndAmbiguous.getPointer();
- }
-
- /// \brief Get the active module macros for this macro.
- ArrayRef<ModuleMacro *> getModuleMacros() const {
- return ModuleMacros;
- }
-
- template<typename Fn> void forAllDefinitions(Fn F) const {
- if (auto *MD = getLocalDirective())
- F(MD->getMacroInfo());
- for (auto *MM : getModuleMacros())
- F(MM->getMacroInfo());
- }
- };
-
bool isMacroDefined(StringRef Id) {
return isMacroDefined(&Identifiers.get(Id));
}
class Decl;
class ASTReader;
class QualType;
-class MacroDefinition;
+class MacroDefinitionRecord;
class MacroInfo;
class Module;
-
+
class ASTDeserializationListener {
public:
virtual ~ASTDeserializationListener();
/// \brief A decl was deserialized from the AST file.
virtual void DeclRead(serialization::DeclID ID, const Decl *D) { }
/// \brief A selector was read from the AST file.
- virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) { }
+ virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
/// \brief A macro definition was read from the AST file.
- virtual void MacroDefinitionRead(serialization::PreprocessedEntityID,
- MacroDefinition *MD) { }
+ virtual void MacroDefinitionRead(serialization::PreprocessedEntityID,
+ MacroDefinitionRecord *MD) {}
/// \brief A module definition was read from the AST file.
- virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) { }
+ virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
};
-
}
#endif
class HeaderSearch;
class HeaderSearchOptions;
class IdentifierResolver;
-class MacroDefinition;
+class MacroDefinitionRecord;
class MacroDirective;
class MacroInfo;
class OpaqueValueExpr;
/// \brief Mapping from macro definitions (as they occur in the preprocessing
/// record) to the macro IDs.
- llvm::DenseMap<const MacroDefinition *, serialization::PreprocessedEntityID>
- MacroDefinitions;
+ llvm::DenseMap<const MacroDefinitionRecord *,
+ serialization::PreprocessedEntityID> MacroDefinitions;
/// \brief Cache of indices of anonymous declarations within their lexical
/// contexts.
void TypeRead(serialization::TypeIdx Idx, QualType T) override;
void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
- MacroDefinition *MD) override;
+ MacroDefinitionRecord *MD) override;
void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override;
// ASTMutationListener implementation.
Previous->SelectorRead(ID, Sel);
}
void MacroDefinitionRead(serialization::PreprocessedEntityID PPID,
- MacroDefinition *MD) override {
+ MacroDefinitionRecord *MD) override {
if (Previous)
Previous->MacroDefinitionRead(PPID, MD);
}
void DeclRead(serialization::DeclID ID, const Decl *D) override;
void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
void MacroDefinitionRead(serialization::PreprocessedEntityID,
- MacroDefinition *MD) override;
+ MacroDefinitionRecord *MD) override;
+
private:
- std::vector<ASTDeserializationListener*> Listeners;
+ std::vector<ASTDeserializationListener *> Listeners;
};
MultiplexASTDeserializationListener::MultiplexASTDeserializationListener(
}
void MultiplexASTDeserializationListener::MacroDefinitionRead(
- serialization::PreprocessedEntityID ID, MacroDefinition *MD) {
+ serialization::PreprocessedEntityID ID, MacroDefinitionRecord *MD) {
for (size_t i = 0, e = Listeners.size(); i != e; ++i)
Listeners[i]->MacroDefinitionRead(ID, MD);
}
return UG.ignoreResults();
}
-bool clang::index::generateUSRForMacro(const MacroDefinition *MD,
+bool clang::index::generateUSRForMacro(const MacroDefinitionRecord *MD,
const SourceManager &SM,
SmallVectorImpl<char> &Buf) {
// Don't generate USRs for things with invalid locations.
// Otherwise, we got an identifier, is it defined to something?
IdentifierInfo *II = PeekTok.getIdentifierInfo();
- Preprocessor::MacroDefinition Macro = PP.getMacroDefinition(II);
+ MacroDefinition Macro = PP.getMacroDefinition(II);
Result.Val = !!Macro;
- Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
+ Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
// If there is a macro, mark it used.
if (Result.Val != 0 && ValueLive)
assert(Entity);
SourceLocation BeginLoc = Entity->getSourceRange().getBegin();
- if (isa<MacroDefinition>(Entity)) {
+ if (isa<MacroDefinitionRecord>(Entity)) {
assert((PreprocessedEntities.empty() ||
- !SourceMgr.isBeforeInTranslationUnit(BeginLoc,
- PreprocessedEntities.back()->getSourceRange().getBegin())) &&
+ !SourceMgr.isBeforeInTranslationUnit(
+ BeginLoc,
+ PreprocessedEntities.back()->getSourceRange().getBegin())) &&
"a macro definition was encountered out-of-order");
PreprocessedEntities.push_back(Entity);
return getPPEntityID(PreprocessedEntities.size()-1, /*isLoaded=*/false);
}
void PreprocessingRecord::RegisterMacroDefinition(MacroInfo *Macro,
- MacroDefinition *Def) {
+ MacroDefinitionRecord *Def) {
MacroDefinitions[Macro] = Def;
}
return Entity;
}
-MacroDefinition *PreprocessingRecord::findMacroDefinition(const MacroInfo *MI) {
- llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos
- = MacroDefinitions.find(MI);
+MacroDefinitionRecord *
+PreprocessingRecord::findMacroDefinition(const MacroInfo *MI) {
+ llvm::DenseMap<const MacroInfo *, MacroDefinitionRecord *>::iterator Pos =
+ MacroDefinitions.find(MI);
if (Pos == MacroDefinitions.end())
return nullptr;
return;
if (MI->isBuiltinMacro())
- addPreprocessedEntity(
- new (*this) MacroExpansion(Id.getIdentifierInfo(),Range));
- else if (MacroDefinition *Def = findMacroDefinition(MI))
- addPreprocessedEntity(
- new (*this) MacroExpansion(Def, Range));
+ addPreprocessedEntity(new (*this)
+ MacroExpansion(Id.getIdentifierInfo(), Range));
+ else if (MacroDefinitionRecord *Def = findMacroDefinition(MI))
+ addPreprocessedEntity(new (*this) MacroExpansion(Def, Range));
}
void PreprocessingRecord::Ifdef(SourceLocation Loc, const Token &MacroNameTok,
const MacroDirective *MD) {
const MacroInfo *MI = MD->getMacroInfo();
SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc());
- MacroDefinition *Def
- = new (*this) MacroDefinition(Id.getIdentifierInfo(), R);
+ MacroDefinitionRecord *Def =
+ new (*this) MacroDefinitionRecord(Id.getIdentifierInfo(), R);
addPreprocessedEntity(Def);
MacroDefinitions[MI] = Def;
}
PreprocessedEntityID
GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
- PreprocessingRecord::PPEntityID
- PPID = PPRec.getPPEntityID(GlobalID-1, /*isLoaded=*/true);
- MacroDefinition *PPDef =
- cast_or_null<MacroDefinition>(PPRec.getPreprocessedEntity(PPID));
+ PreprocessingRecord::PPEntityID PPID =
+ PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true);
+ MacroDefinitionRecord *PPDef = cast_or_null<MacroDefinitionRecord>(
+ PPRec.getPreprocessedEntity(PPID));
if (PPDef)
PPRec.RegisterMacroDefinition(Macro, PPDef);
}
case PPD_MACRO_EXPANSION: {
bool isBuiltin = Record[0];
IdentifierInfo *Name = nullptr;
- MacroDefinition *Def = nullptr;
+ MacroDefinitionRecord *Def = nullptr;
if (isBuiltin)
Name = getLocalIdentifier(M, Record[1]);
else {
- PreprocessedEntityID
- GlobalID = getGlobalPreprocessedEntityID(M, Record[1]);
- Def =cast<MacroDefinition>(PPRec.getLoadedPreprocessedEntity(GlobalID-1));
+ PreprocessedEntityID GlobalID =
+ getGlobalPreprocessedEntityID(M, Record[1]);
+ Def = cast<MacroDefinitionRecord>(
+ PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
}
MacroExpansion *ME;
// Decode the identifier info and then check again; if the macro is
// still defined and associated with the identifier,
IdentifierInfo *II = getLocalIdentifier(M, Record[0]);
- MacroDefinition *MD
- = new (PPRec) MacroDefinition(II, Range);
+ MacroDefinitionRecord *MD = new (PPRec) MacroDefinitionRecord(II, Range);
if (DeserializationListener)
DeserializationListener->MacroDefinitionRead(PPID, MD);
(void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
Record.clear();
- PreprocessedEntityOffsets.push_back(PPEntityOffset((*E)->getSourceRange(),
- Stream.GetCurrentBitNo()));
+ PreprocessedEntityOffsets.push_back(
+ PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo()));
- if (MacroDefinition *MD = dyn_cast<MacroDefinition>(*E)) {
+ if (MacroDefinitionRecord *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
// Record this macro definition's ID.
MacroDefinitions[MD] = NextPreprocessorEntityID;
-
+
AddIdentifierRef(MD->getName(), Record);
Stream.EmitRecord(PPD_MACRO_DEFINITION, Record);
continue;
}
void ASTWriter::MacroDefinitionRead(serialization::PreprocessedEntityID ID,
- MacroDefinition *MD) {
+ MacroDefinitionRecord *MD) {
assert(MacroDefinitions.find(MD) == MacroDefinitions.end());
MacroDefinitions[MD] = ID;
}
if (MacroExpansion *ME = dyn_cast<MacroExpansion>(PPE)) {
if (Visit(MakeMacroExpansionCursor(ME, TU)))
return true;
-
+
continue;
}
-
- if (MacroDefinition *MD = dyn_cast<MacroDefinition>(PPE)) {
+
+ if (MacroDefinitionRecord *MD = dyn_cast<MacroDefinitionRecord>(PPE)) {
if (Visit(MakeMacroDefinitionCursor(MD, TU)))
return true;
-
+
continue;
}
SourceLocation Loc = AU->mapLocationToPreamble(BeginLoc);
const MacroInfo *MI =
getMacroInfo(cxcursor::getCursorMacroDefinition(Cursor), TU);
- if (MacroDefinition *MacroDef =
- checkForMacroInMacroDefinition(MI, Loc, TU))
+ if (MacroDefinitionRecord *MacroDef =
+ checkForMacroInMacroDefinition(MI, Loc, TU))
return Visit(cxcursor::MakeMacroExpansionCursor(MacroDef, BeginLoc, TU));
}
return clang_getNullCursor();
}
-
+
if (C.kind == CXCursor_MacroExpansion) {
- if (const MacroDefinition *Def = getCursorMacroExpansion(C).getDefinition())
+ if (const MacroDefinitionRecord *Def =
+ getCursorMacroExpansion(C).getDefinition())
return MakeMacroDefinitionCursor(Def, tu);
}
if (MI) {
SourceLocation SaveLoc = Tok.getLocation();
Tok.setLocation(CXXUnit->mapLocationToPreamble(SaveLoc));
- MacroDefinition *MacroDef = checkForMacroInMacroDefinition(MI,Tok,TU);
+ MacroDefinitionRecord *MacroDef =
+ checkForMacroInMacroDefinition(MI, Tok, TU);
Tok.setLocation(SaveLoc);
if (MacroDef)
- Cursors[NextIdx-1] = MakeMacroExpansionCursor(MacroDef,
- Tok.getLocation(), TU);
+ Cursors[NextIdx - 1] =
+ MakeMacroExpansionCursor(MacroDef, Tok.getLocation(), TU);
}
} while (!Tok.isAtStartOfLine());
return nullptr;
}
-const MacroInfo *cxindex::getMacroInfo(const MacroDefinition *MacroDef,
+const MacroInfo *cxindex::getMacroInfo(const MacroDefinitionRecord *MacroDef,
CXTranslationUnit TU) {
if (!MacroDef || !TU)
return nullptr;
return getMacroInfo(*II, MacroDef->getLocation(), TU);
}
-MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI,
- const Token &Tok,
- CXTranslationUnit TU) {
+MacroDefinitionRecord *
+cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI, const Token &Tok,
+ CXTranslationUnit TU) {
if (!MI || !TU)
return nullptr;
if (Tok.isNot(tok::raw_identifier))
return PPRec->findMacroDefinition(InnerMD->getMacroInfo());
}
-MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI,
- SourceLocation Loc,
- CXTranslationUnit TU) {
+MacroDefinitionRecord *
+cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI, SourceLocation Loc,
+ CXTranslationUnit TU) {
if (Loc.isInvalid() || !MI || !TU)
return nullptr;
}
namespace clang {
- class ASTUnit;
- class MacroInfo;
- class MacroDefinition;
- class SourceLocation;
- class Token;
- class IdentifierInfo;
+class ASTUnit;
+class MacroInfo;
+class MacroDefinitionRecord;
+class SourceLocation;
+class Token;
+class IdentifierInfo;
class CIndexer {
bool OnlyLocalDecls;
/// \brief If \c MacroDefLoc points at a macro definition with \c II as
/// its name, this retrieves its MacroInfo.
MacroInfo *getMacroInfo(const IdentifierInfo &II,
- SourceLocation MacroDefLoc,
- CXTranslationUnit TU);
+ SourceLocation MacroDefLoc, CXTranslationUnit TU);
- /// \brief Retrieves the corresponding MacroInfo of a MacroDefinition.
- const MacroInfo *getMacroInfo(const MacroDefinition *MacroDef,
+ /// \brief Retrieves the corresponding MacroInfo of a MacroDefinitionRecord.
+ const MacroInfo *getMacroInfo(const MacroDefinitionRecord *MacroDef,
CXTranslationUnit TU);
/// \brief If \c Loc resides inside the definition of \c MI and it points at
/// an identifier that has ever been a macro name, this returns the latest
- /// MacroDefinition for that name, otherwise it returns NULL.
- MacroDefinition *checkForMacroInMacroDefinition(const MacroInfo *MI,
- SourceLocation Loc,
- CXTranslationUnit TU);
+ /// MacroDefinitionRecord for that name, otherwise it returns NULL.
+ MacroDefinitionRecord *checkForMacroInMacroDefinition(const MacroInfo *MI,
+ SourceLocation Loc,
+ CXTranslationUnit TU);
/// \brief If \c Tok resides inside the definition of \c MI and it points at
/// an identifier that has ever been a macro name, this returns the latest
- /// MacroDefinition for that name, otherwise it returns NULL.
- MacroDefinition *checkForMacroInMacroDefinition(const MacroInfo *MI,
- const Token &Tok,
- CXTranslationUnit TU);
- }
-}
+ /// MacroDefinitionRecord for that name, otherwise it returns NULL.
+ MacroDefinitionRecord *checkForMacroInMacroDefinition(const MacroInfo *MI,
+ const Token &Tok,
+ CXTranslationUnit TU);
+ }
+ }
#endif
return TU->mapRangeFromPreamble(Range);
}
-CXCursor cxcursor::MakeMacroDefinitionCursor(const MacroDefinition *MI,
+CXCursor cxcursor::MakeMacroDefinitionCursor(const MacroDefinitionRecord *MI,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_MacroDefinition, 0, { MI, nullptr, TU } };
+ CXCursor C = {CXCursor_MacroDefinition, 0, {MI, nullptr, TU}};
return C;
}
-const MacroDefinition *cxcursor::getCursorMacroDefinition(CXCursor C) {
+const MacroDefinitionRecord *cxcursor::getCursorMacroDefinition(CXCursor C) {
assert(C.kind == CXCursor_MacroDefinition);
- return static_cast<const MacroDefinition *>(C.data[0]);
+ return static_cast<const MacroDefinitionRecord *>(C.data[0]);
}
-CXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI,
+CXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI,
CXTranslationUnit TU) {
CXCursor C = { CXCursor_MacroExpansion, 0, { MI, nullptr, TU } };
return C;
}
-CXCursor cxcursor::MakeMacroExpansionCursor(MacroDefinition *MI,
+CXCursor cxcursor::MakeMacroExpansionCursor(MacroDefinitionRecord *MI,
SourceLocation Loc,
CXTranslationUnit TU) {
assert(Loc.isValid());
- CXCursor C = { CXCursor_MacroExpansion, 0, { MI, Loc.getPtrEncoding(), TU } };
+ CXCursor C = {CXCursor_MacroExpansion, 0, {MI, Loc.getPtrEncoding(), TU}};
return C;
}
return getAsMacroDefinition()->getName();
return getAsMacroExpansion()->getName();
}
-const MacroDefinition *cxcursor::MacroExpansionCursor::getDefinition() const {
+const MacroDefinitionRecord *
+cxcursor::MacroExpansionCursor::getDefinition() const {
if (isPseudo())
return getAsMacroDefinition();
return getAsMacroExpansion()->getDefinition();
true);
return String;
}
- }
- else if (kind == CXCursor_MacroDefinition) {
- const MacroDefinition *definition = getCursorMacroDefinition(cursor);
+ } else if (kind == CXCursor_MacroDefinition) {
+ const MacroDefinitionRecord *definition = getCursorMacroDefinition(cursor);
const IdentifierInfo *MacroInfo = definition->getName();
ASTUnit *unit = getCursorASTUnit(cursor);
CodeCompletionResult Result(MacroInfo);
- CodeCompletionString *String
- = Result.CreateCodeCompletionString(unit->getASTContext(),
- unit->getPreprocessor(),
- unit->getCodeCompletionTUInfo().getAllocator(),
- unit->getCodeCompletionTUInfo(),
- false);
+ CodeCompletionString *String = Result.CreateCodeCompletionString(
+ unit->getASTContext(), unit->getPreprocessor(),
+ unit->getCodeCompletionTUInfo().getAllocator(),
+ unit->getCodeCompletionTUInfo(), false);
return String;
}
return nullptr;
class FieldDecl;
class InclusionDirective;
class LabelStmt;
-class MacroDefinition;
+class MacroDefinitionRecord;
class MacroExpansion;
class NamedDecl;
class ObjCInterfaceDecl;
SourceRange getCursorPreprocessingDirective(CXCursor C);
/// \brief Create a macro definition cursor.
-CXCursor MakeMacroDefinitionCursor(const MacroDefinition *,
+CXCursor MakeMacroDefinitionCursor(const MacroDefinitionRecord *,
CXTranslationUnit TU);
/// \brief Unpack a given macro definition cursor to retrieve its
/// source range.
-const MacroDefinition *getCursorMacroDefinition(CXCursor C);
+const MacroDefinitionRecord *getCursorMacroDefinition(CXCursor C);
/// \brief Create a macro expansion cursor.
-CXCursor MakeMacroExpansionCursor(MacroExpansion *,
- CXTranslationUnit TU);
+CXCursor MakeMacroExpansionCursor(MacroExpansion *, CXTranslationUnit TU);
/// \brief Create a "pseudo" macro expansion cursor, using a macro definition
/// and a source location.
-CXCursor MakeMacroExpansionCursor(MacroDefinition *, SourceLocation Loc,
+CXCursor MakeMacroExpansionCursor(MacroDefinitionRecord *, SourceLocation Loc,
CXTranslationUnit TU);
/// \brief Wraps a macro expansion cursor and provides a common interface
class MacroExpansionCursor {
CXCursor C;
- bool isPseudo() const {
- return C.data[1] != nullptr;
- }
- const MacroDefinition *getAsMacroDefinition() const {
+ bool isPseudo() const { return C.data[1] != nullptr; }
+ const MacroDefinitionRecord *getAsMacroDefinition() const {
assert(isPseudo());
- return static_cast<const MacroDefinition *>(C.data[0]);
+ return static_cast<const MacroDefinitionRecord *>(C.data[0]);
}
const MacroExpansion *getAsMacroExpansion() const {
assert(!isPseudo());
}
const IdentifierInfo *getName() const;
- const MacroDefinition *getDefinition() const;
+ const MacroDefinitionRecord *getDefinition() const;
SourceRange getSourceRange() const;
};