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


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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to