forked from qt-creator/qt-creator
C++: add include-guard tracking.
Track the typical #ifndef/#define/#endif usage in header files to see if the macro is an include guard. If so, store it in the Document. No behavioural change, just recording the name. This can be used in the future to track if a file needs to be re-parsed when a macro changes: if it was used in the file, and not defined in it nor being the include-guard, a file should be re-preprocessed and re-parsed. It can also be used to check if two files have the same include guard. Change-Id: I2715f529997a7b24a11bdbc6150652e2669f1a46 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -312,6 +312,11 @@ public:
|
||||
QList<UndefinedMacroUse> undefinedMacroUses() const
|
||||
{ return _undefinedMacroUses; }
|
||||
|
||||
void setIncludeGuardMacroName(const QByteArray &includeGuardMacroName)
|
||||
{ _includeGuardMacroName = includeGuardMacroName; }
|
||||
QByteArray includeGuardMacroName() const
|
||||
{ return _includeGuardMacroName; }
|
||||
|
||||
const Macro *findMacroDefinitionAt(unsigned line) const;
|
||||
const MacroUse *findMacroUseAt(unsigned offset) const;
|
||||
const UndefinedMacroUse *findUndefinedMacroUseAt(unsigned offset) const;
|
||||
@@ -327,12 +332,19 @@ private:
|
||||
Control *_control;
|
||||
TranslationUnit *_translationUnit;
|
||||
Namespace *_globalNamespace;
|
||||
|
||||
/// All messages generated during lexical/syntactic/semantic analysis.
|
||||
QList<DiagnosticMessage> _diagnosticMessages;
|
||||
|
||||
QList<Include> _includes;
|
||||
QList<Macro> _definedMacros;
|
||||
QList<Block> _skippedBlocks;
|
||||
QList<MacroUse> _macroUses;
|
||||
QList<UndefinedMacroUse> _undefinedMacroUses;
|
||||
|
||||
/// the macro name of the include guard, if there is one.
|
||||
QByteArray _includeGuardMacroName;
|
||||
|
||||
QByteArray _source;
|
||||
QDateTime _lastModified;
|
||||
QAtomicInt _keepSourceAndASTCount;
|
||||
|
||||
Reference in New Issue
Block a user