Skip to content

Commit 61beffe

Browse files
jonsimantova-maurice
authored andcommitted
Added a test for C++ namespace renaming to Blastdoor tests, and added a fix to
rename symbols that are external references implemented in other files. This fixes a Blastdoor issue where a symbol that needs to be renamed is passed between multiple internal libraries -- it needs to be renamed regardless of whether its implementation is present or if it is an external symbol. PiperOrigin-RevId: 333175764
1 parent c33ef95 commit 61beffe

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

merge_libraries_test_file.cc

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
/* This is a test file for merge_libraries.py tests. It contains some C and C++
1818
* symbols that merge_libraries can rename. */
1919

20+
#include <memory>
21+
#include <string>
22+
#include <utility>
23+
#include <vector>
24+
2025
extern "C" {
2126
int test_symbol(void) { return 1; } // NOLINT
2227

@@ -34,11 +39,15 @@ namespace test_namespace {
3439
class TestClass {
3540
public:
3641
TestClass();
42+
TestClass(const TestClass&); // not in this file
43+
TestClass(const TestClass&&); // not in this file
44+
~TestClass(); // not in this file
3745
int TestMethod();
3846
int TestMethodNotInThisfile();
39-
int TestStaticMethod();
40-
int TestStaticMethodNotInThisFile();
41-
static int test_static_field; // NOLINT
47+
static int TestStaticMethod();
48+
static int TestStaticMethodNotInThisFile();
49+
static int test_static_field; // NOLINT
50+
static int test_static_field_not_in_this_file; // NOLINT
4251
};
4352

4453
int global_cpp_symbol = 12345; // NOLINT
@@ -47,8 +56,28 @@ int TestClass::test_static_field;
4756

4857
TestClass::TestClass() {}
4958

50-
int TestClass::TestMethod() { return not_in_this_file(); }
59+
int TestClass::TestMethod() {
60+
return TestMethodNotInThisfile() + not_in_this_file();
61+
}
5162

5263
int TestClass::TestStaticMethod() { return TestStaticMethodNotInThisFile(); }
5364

5465
} // namespace test_namespace
66+
67+
void GlobalFunctionWithParameter(test_namespace::TestClass const&, int) {}
68+
69+
void GlobalFunctionWithMultipleParameters(
70+
test_namespace::TestClass* p1, std::vector<test_namespace::TestClass> p2,
71+
std::unique_ptr<test_namespace::TestClass> p3,
72+
std::vector<std::unique_ptr<test_namespace::TestClass>> p4, std::string) {
73+
p2.push_back(*p1);
74+
p2.pop_back();
75+
p4.push_back(std::move(p3));
76+
p4.pop_back();
77+
}
78+
79+
extern void ExternFunctionWithParameter(test_namespace::TestClass&&, int);
80+
81+
extern void ExternFunctionWithMultipleParameters(
82+
const test_namespace::TestClass&,
83+
std::unique_ptr<test_namespace::TestClass>, std::string);

0 commit comments

Comments
 (0)