ppluzhnikov updated this revision to Diff 416330.
ppluzhnikov added a comment.
Use single quotes in sed -- don't want shell expansion there.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121733/new/
https://reviews.llvm.org/D121733
Files:
clang-tools-extra/test/clang-apply-replacements/order-dependent.cpp
clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
clang/bindings/python/tests/cindex/test_translation_unit.py
clang/lib/Basic/FileManager.cpp
clang/test/Frontend/dependency-gen.c
clang/test/Index/skip-parsed-bodies/compile_commands.json
clang/test/Modules/filename.cpp
clang/unittests/Lex/HeaderSearchTest.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp
clang/unittests/Tooling/TransformerTest.cpp
Index: clang/unittests/Tooling/TransformerTest.cpp
===================================================================
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1593,21 +1593,22 @@
return L.getFilePath() < R.getFilePath();
});
- ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
- EXPECT_THAT(Changes[0].getInsertedHeaders(), IsEmpty());
- EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
+ const auto &change_h = Changes[1];
+ ASSERT_EQ(change_h.getFilePath(), "input.h");
+ EXPECT_THAT(change_h.getInsertedHeaders(), IsEmpty());
+ EXPECT_THAT(change_h.getRemovedHeaders(), IsEmpty());
llvm::Expected<std::string> UpdatedCode =
- clang::tooling::applyAllReplacements(Header,
- Changes[0].getReplacements());
+ clang::tooling::applyAllReplacements(Header, change_h.getReplacements());
ASSERT_TRUE(static_cast<bool>(UpdatedCode))
<< "Could not update code: " << llvm::toString(UpdatedCode.takeError());
EXPECT_EQ(format(*UpdatedCode), "");
- ASSERT_EQ(Changes[1].getFilePath(), "input.cc");
- EXPECT_THAT(Changes[1].getInsertedHeaders(), IsEmpty());
- EXPECT_THAT(Changes[1].getRemovedHeaders(), IsEmpty());
- UpdatedCode = clang::tooling::applyAllReplacements(
- Source, Changes[1].getReplacements());
+ const auto &change_cc = Changes[0];
+ ASSERT_EQ(change_cc.getFilePath(), "input.cc");
+ EXPECT_THAT(change_cc.getInsertedHeaders(), IsEmpty());
+ EXPECT_THAT(change_cc.getRemovedHeaders(), IsEmpty());
+ UpdatedCode =
+ clang::tooling::applyAllReplacements(Source, change_cc.getReplacements());
ASSERT_TRUE(static_cast<bool>(UpdatedCode))
<< "Could not update code: " << llvm::toString(UpdatedCode.takeError());
EXPECT_EQ(format(*UpdatedCode), format("#include \"input.h\"\n"));
@@ -1630,7 +1631,7 @@
{{"input.h", Header}}));
ASSERT_EQ(Changes.size(), 1U);
- ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
+ ASSERT_EQ(Changes[0].getFilePath(), "input.h");
EXPECT_THAT(Changes[0].getInsertedHeaders(), ElementsAre("header.h"));
EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
llvm::Expected<std::string> UpdatedCode =
@@ -1679,7 +1680,7 @@
ResultOf([](const AtomicChange &C) { return C.getFilePath(); },
"input.cc"),
ResultOf([](const AtomicChange &C) { return C.getFilePath(); },
- "./input.h"))));
+ "input.h"))));
}
} // namespace
Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===================================================================
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -292,7 +292,7 @@
{"int main() {}",
R"(expanded tokens:
int main ( ) { }
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
int main ( ) { }
no mappings.
@@ -301,7 +301,7 @@
{"\t\n int\t\n main\t\n (\t\n )\t\n{\t\n }\t\n",
R"(expanded tokens:
int main ( ) { }
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
int main ( ) { }
no mappings.
@@ -313,7 +313,7 @@
)cpp",
R"(expanded tokens:
<empty>
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# pragma GCC visibility push ( public ) # pragma GCC visibility pop
mappings:
@@ -322,7 +322,7 @@
// Empty files should not crash.
{R"cpp()cpp", R"(expanded tokens:
<empty>
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
<empty>
no mappings.
@@ -336,7 +336,7 @@
)cpp",
R"(expanded tokens:
a
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
a # define MACRO ( ) A # B
mappings:
@@ -401,7 +401,7 @@
std::string Expected =
"expanded tokens:\n"
" int a ;\n"
- "file './input.cpp'\n"
+ "file 'input.cpp'\n"
" spelled tokens:\n"
" # define FOO a # include \"unresolved_file.h\" # undef FOO "
"# ifdef X # else # endif # ifndef Y # endif # if 1 # elif 2 # else "
@@ -420,7 +420,7 @@
)cpp",
R"(expanded tokens:
int const a ;
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# define INT int const INT a ;
mappings:
@@ -434,7 +434,7 @@
)cpp",
R"(expanded tokens:
const int a ;
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# define INT ( a ) const int INT ( 10 + 10 ) a ;
mappings:
@@ -449,7 +449,7 @@
)cpp",
R"(expanded tokens:
int const a ;
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# define ID ( X ) X # define INT int const ID ( ID ( INT ) ) a ;
mappings:
@@ -465,7 +465,7 @@
)cpp",
"expanded tokens:\n"
" int a = 1 * 2 + 3 * 4 + 5 ;\n"
- "file './input.cpp'\n"
+ "file 'input.cpp'\n"
" spelled tokens:\n"
" # define ADD ( X , Y ) X + Y # define MULT ( X , Y ) X * Y int "
"a = ADD ( MULT ( 1 , 2 ) , MULT ( 3 , ADD ( 4 , 5 ) ) ) ;\n"
@@ -482,7 +482,7 @@
)cpp",
R"(expanded tokens:
<empty>
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# define EMPTY # define EMPTY_FUNC ( X ) EMPTY EMPTY_FUNC ( 1 + 2 + 3 )
mappings:
@@ -497,7 +497,7 @@
)cpp",
R"(expanded tokens:
int a = 10 + 10 ;
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# define FOO 10 + 10 ; int a = FOO
mappings:
@@ -512,7 +512,7 @@
)cpp",
R"(expanded tokens:
1 + 42
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# define NUM 42 # define ID ( a ) a # define M 1 + ID M ( NUM )
mappings:
@@ -601,19 +601,19 @@
std::string Expected = R"(expanded tokens:
int a = 100 ; int b = 1 + 2 ; int c = 1 + 2 * 3 ;
-file './input.cpp'
+file 'input.cpp'
spelled tokens:
# include "foo.h" int c = ADD ( 1 , MULT ( 2 , 3 ) ) ;
mappings:
['#'_0, 'int'_3) => ['int'_12, 'int'_12)
['ADD'_6, ';'_17) => ['1'_15, ';'_20)
-file './foo.h'
+file 'foo.h'
spelled tokens:
# define ADD ( X , Y ) X + Y int a = 100 ; # include "bar.h"
mappings:
['#'_0, 'int'_11) => ['int'_0, 'int'_0)
['#'_16, '<eof>'_19) => ['int'_5, 'int'_5)
-file './bar.h'
+file 'bar.h'
spelled tokens:
int b = ADD ( 1 , 2 ) ; # define MULT ( X , Y ) X * Y
mappings:
Index: clang/unittests/Lex/HeaderSearchTest.cpp
===================================================================
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -112,6 +112,23 @@
}
TEST_F(HeaderSearchTest, Dots) {
+ VFS->addFile("./inc/./foo.h", 0, nullptr, /*User=*/None, /*Group=*/None,
+ llvm::sys::fs::file_type::regular_file);
+ llvm::Expected<FileEntryRef> FileRef = FileMgr.getFileRef("inc/foo.h", false);
+ assert(FileRef);
+ const auto *const FE = &FileRef->getFileEntry();
+ EXPECT_EQ(StringRef(FileRef->getName()), StringRef("inc/foo.h"));
+
+ FileRef = FileMgr.getFileRef("./inc/./foo.h", false);
+ assert(FileRef);
+ EXPECT_EQ(StringRef(FileRef->getName()), StringRef("inc/foo.h"));
+ EXPECT_EQ(FE, &FileRef->getFileEntry());
+
+ FileRef = FileMgr.getFileRef("inc/./foo.h", false);
+ assert(FileRef);
+ EXPECT_EQ(StringRef(FileRef->getName()), StringRef("inc/foo.h"));
+ EXPECT_EQ(FE, &FileRef->getFileEntry());
+
addSearchDir("/x/./y/");
EXPECT_EQ(Search.suggestPathToFileForDiagnostics("/x/y/./z",
/*WorkingDir=*/"",
Index: clang/test/Modules/filename.cpp
===================================================================
--- clang/test/Modules/filename.cpp
+++ clang/test/Modules/filename.cpp
@@ -5,4 +5,4 @@
// Make sure that headers that are referenced by module maps have __FILE__
// reflect the include path they were found with.
-// CHECK: const char *p = "./Inputs/filename/a.h"
+// CHECK: const char *p = "Inputs/filename/a.h"
Index: clang/test/Index/skip-parsed-bodies/compile_commands.json
===================================================================
--- clang/test/Index/skip-parsed-bodies/compile_commands.json
+++ clang/test/Index/skip-parsed-bodies/compile_commands.json
@@ -22,14 +22,14 @@
// CHECK-NEXT: [enteredMainFile]: t1.cpp
// CHECK: [indexDeclaration]: kind: c++-instance-method | name: method_decl | {{.*}} | isRedecl: 0 | isDef: 0 | isContainer: 0
// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: method_def1 | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: 1
-// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: ./t.h:9:27
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: t.h:9:27
// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: method_def2 | {{.*}} | isRedecl: 0 | isDef: 0 | isContainer: 0
// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: method_def2 | {{.*}} | isRedecl: 1 | isDef: 1 | isContainer: 1
// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS |
// CHECK-NEXT: [indexEntityReference]: kind: c++-class | name: C |
-// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: ./t.h:15:5
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: t.h:15:5
// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo1 | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: 1
-// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: ./t.h:19:5
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: t.h:19:5
// CHECK-NEXT: [diagnostic]: {{.*}} undeclared identifier 'undef_val1'
// CHECK-NEXT: [diagnostic]: {{.*}} undeclared identifier 'undef_val2'
// CHECK-NEXT: [diagnostic]: {{.*}} undeclared identifier 'undef_val3'
@@ -43,13 +43,13 @@
// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS |
// CHECK-NEXT: [indexEntityReference]: kind: c++-class | name: C |
// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo1 | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: skipped
-// CHECK-NEXT: [ppIncludedFile]: ./pragma_once.h
+// CHECK-NEXT: [ppIncludedFile]: pragma_once.h
// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo2 | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: 1
-// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: ./t.h:25:5
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: t.h:25:5
// CHECK: [indexDeclaration]: kind: c++-instance-method | name: tsmeth | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: 1
-// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: ./pragma_once.h:8:7
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: pragma_once.h:8:7
// CHECK: [indexDeclaration]: kind: function | name: imp_foo | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: 1
-// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: ./imported.h:4:5
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: some_val | {{.*}} | loc: imported.h:4:5
// CHECK-NEXT: [diagnostic]: {{.*}} undeclared identifier 'undef_val4'
// CHECK-NEXT: [diagnostic]: {{.*}} undeclared identifier 'undef_tsval'
// CHECK-NEXT: [diagnostic]: {{.*}} undeclared identifier 'undef_impval'
@@ -63,9 +63,9 @@
// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS |
// CHECK-NEXT: [indexEntityReference]: kind: c++-class | name: C |
// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo1 | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: skipped
-// CHECK-NEXT: [ppIncludedFile]: ./pragma_once.h
+// CHECK-NEXT: [ppIncludedFile]: pragma_once.h
// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo2 | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: skipped
-// CHECK-NEXT: [indexDeclaration]: kind: variable | {{.*}} | loc: ./pragma_once.h:3:12
+// CHECK-NEXT: [indexDeclaration]: kind: variable | {{.*}} | loc: pragma_once.h:3:12
// CHECK: [indexDeclaration]: kind: c++-instance-method | name: tsmeth | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: skipped
// CHECK-NOT: [indexEntityReference]: kind: variable | name: some_val |
// CHECK: [indexDeclaration]: kind: function | name: imp_foo | {{.*}} | isRedecl: 0 | isDef: 1 | isContainer: skipped
Index: clang/test/Frontend/dependency-gen.c
===================================================================
--- clang/test/Frontend/dependency-gen.c
+++ clang/test/Frontend/dependency-gen.c
@@ -16,7 +16,7 @@
// RUN: %clang -MD -MF - %s -fsyntax-only -I .//./a/b/ | FileCheck -check-prefix=CHECK-FOUR %s
// CHECK-FOUR: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b/. | FileCheck -check-prefix=CHECK-FIVE %s
-// CHECK-FIVE: {{ }}a{{[/\\]}}b{{[/\\]}}.{{[/\\]}}x.h
+// CHECK-FIVE: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
// RUN: cd a/b
// RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
// CHECK-SIX: {{ }}x.h
Index: clang/lib/Basic/FileManager.cpp
===================================================================
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -204,6 +204,10 @@
FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) {
++NumFileLookups;
+ SmallString<128> CleanFilename = Filename;
+ llvm::sys::path::remove_dots(CleanFilename);
+ Filename = CleanFilename;
+
// See if there is already an entry in the map.
auto SeenFileInsertResult =
SeenFileEntries.insert({Filename, std::errc::no_such_file_or_directory});
Index: clang/bindings/python/tests/cindex/test_translation_unit.py
===================================================================
--- clang/bindings/python/tests/cindex/test_translation_unit.py
+++ clang/bindings/python/tests/cindex/test_translation_unit.py
@@ -85,7 +85,7 @@
int x;
int SOME_DEFINE;
"""),
- ('./fake.h', """
+ ('fake.h', """
#define SOME_DEFINE y
""")
])
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
@@ -7,7 +7,7 @@
/// Warning will be triggered on code that is not internal that is included.
#include "absl/external-file.h"
-// CHECK: absl/external-file.h:1:11: warning: namespace 'absl' is reserved
+// CHECK: absl{{[/\\]}}external-file.h:1:11: warning: namespace 'absl' is reserved
namespace absl {}
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'absl' is reserved for implementation of the Abseil library and should not be opened in user code [abseil-no-namespace]
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
@@ -6,7 +6,7 @@
// CHECK-NOT: warning:
#include "absl/external-file.h"
-// CHECK: absl/external-file.h:6:24: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil [abseil-no-internal-dependencies]
+// CHECK: absl{{[/\\]}}external-file.h:6:24: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil [abseil-no-internal-dependencies]
void DirectAcess() {
absl::strings_internal::InternalFunction();
Index: clang-tools-extra/test/clang-apply-replacements/order-dependent.cpp
===================================================================
--- clang-tools-extra/test/clang-apply-replacements/order-dependent.cpp
+++ clang-tools-extra/test/clang-apply-replacements/order-dependent.cpp
@@ -4,4 +4,5 @@
// RUN: sed "s#\$(path)#%/T/Inputs/order-dependent#" %S/Inputs/order-dependent/file2.yaml > %T/Inputs/order-dependent/file2.yaml
// RUN: sed "s#\$(path)#%/T/Inputs/order-dependent#" %S/Inputs/order-dependent/expected.txt > %T/Inputs/order-dependent/expected.txt
// RUN: not clang-apply-replacements %T/Inputs/order-dependent > %T/Inputs/order-dependent/output.txt 2>&1
-// RUN: diff -b %T/Inputs/order-dependent/output.txt %T/Inputs/order-dependent/expected.txt
+// RUN: sed 's#\\#/#g' %T/Inputs/order-dependent/output.txt > %T/Inputs/order-dependent/output-u.txt
+// RUN: diff -b %T/Inputs/order-dependent/output-u.txt %T/Inputs/order-dependent/expected.txt
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits