forked from OSchip/llvm-project
[clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include
Previously, double slashes (//) occurring in angle brackets #include were incorrectly interpreted as comments. eg. #include <dir//file.h> Differential Revision: https://reviews.llvm.org/D66550 llvm-svn: 369988
This commit is contained in:
parent
ba7e191e43
commit
6137cecf87
|
@ -186,8 +186,8 @@ static void skipRawString(const char *&First, const char *const End) {
|
|||
}
|
||||
|
||||
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 @@ void Minimizer::printToNewline(const char *&First, const char *const End) {
|
|||
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
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue