[PATCH] D66550: [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 16:28:21 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369988: [clang-scan-deps] Minimizer: Correctly skip over double slashes in angleā€¦ (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66550?vs=216461&id=217264#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66550

Files:
  cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c


Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
===================================================================
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -0,0 +1,8 @@
+// Test double slashes in #include directive along with angle brackets. Previously, this was interpreted as comments.
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %s 2>&1 | FileCheck %s
+
+#include "a//b.h"
+#include <a//b.h>
+
+// CHECK: #include "a//b.h"
+// CHECK: #include <a//b.h>
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===================================================================
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *&First, const char *const End) {
-  assert(*First == '\'' || *First == '"');
-  const char Terminator = *First;
+  assert(*First == '\'' || *First == '"' || *First == '<');
+  const char Terminator = *First == '<' ? '>' : *First;
   for (++First; First != End && *First != Terminator; ++First)
     if (*First == '\\')
       if (++First == End)
@@ -363,7 +363,8 @@
     const char *Last = First;
     do {
       // Iterate over strings correctly to avoid comments and newlines.
-      if (*Last == '"' || *Last == '\'') {
+      if (*Last == '"' || *Last == '\'' ||
+          (*Last == '<' && top() == pp_include)) {
         if (LLVM_UNLIKELY(isRawStringLiteral(First, Last)))
           skipRawString(Last, End);
         else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66550.217264.patch
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190826/b4061458/attachment.bin>


More information about the llvm-commits mailing list