[PATCH] D67536: [clangd] Inactive regions support as an extension to semantic highlighting

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 12 14:21:49 PST 2019


nridge added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:143
+    for (const SourceRange &R :
+         AST.getPreprocessor().getPreprocessingRecord()->getSkippedRanges()) {
+      if (isInsideMainFile(R.getBegin(), SM)) {
----------------
hokein wrote:
> I think the current implementation only collects the skipped preprocessing ranges **after preamble** region in the main file.  We probably need to store these ranges in PreambleData to make the ranges in the preamble region work, no need to do it in this patch, but we'd better have a test reflecting this fact. 
> 
> ```
> #ifdef ActiveCOde
> // inactive code here
> #endif
> 
> #include "foo.h"
> // preamble ends here
> 
> namespace ns {
> // ..
> }  
> ```
Your observation is correct: the current implementation only highlights inactive lines after the preamble. For now, I added a test case with a FIXME for this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67536/new/

https://reviews.llvm.org/D67536





More information about the cfe-commits mailing list