[cfe-commits] [PATCH] Make PreprocessorLexer's ConditionalStack available to clients

Douglas Gregor dgregor at apple.com
Mon Oct 18 07:46:07 PDT 2010


On Oct 14, 2010, at 12:01 AM, Magnus Reftel wrote:

> Hi,
> 
> I recently needed to inspect the conditional stack of the preprocessor
> for a small tool I wrote that annotates source code. I think the
> ability to see why the preprocessor is including/excluding a line
> could be useful for others. Attached, please find a trivial patch that
> adds a public accessor function for ConditionalStack. I would much
> appreciate if this could be applied to the trunk.

--- llvm-116392/tools/clang/include/clang/Lex/PreprocessorLexer.h	2010-10-13 07:16:35.453569900 +0200
+++ llvm-116392-ConditionalStack/tools/clang/include/clang/Lex/PreprocessorLexer.h	2010-10-13 14:57:57.185845900 +0200
@@ -155,6 +155,10 @@
   /// getFileEntry - Return the FileEntry corresponding to this FileID.  Like
   /// getFileID(), this only works for lexers with attached preprocessors.
   const FileEntry *getFileEntry() const;
+
+  llvm::SmallVector<PPConditionalInfo, 4> getConditionalStack() const {
+    return ConditionalStack;
+  }
 };

I'd rather not force a copy to access this data; so, I've added an iterator-based interface to the conditional stack in Clang r116703.

	- Doug



More information about the cfe-commits mailing list