]> granicus.if.org Git - clang/commitdiff
[ASTImporter] Turn StringRefs back to std::strings to avoid use-after-free
authorAleksei Sidorin <a.sidorin@samsung.com>
Mon, 14 May 2018 16:12:31 +0000 (16:12 +0000)
committerAleksei Sidorin <a.sidorin@samsung.com>
Mon, 14 May 2018 16:12:31 +0000 (16:12 +0000)
This is a workaround for the issue in buildASTFromCodeWithArgs()
where a local buffer can be used to store the program text
referred by SourceManager.
FIXME: Fix the root issue in buildASTFromCodeWithArgs().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332256 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/AST/ASTImporterTest.cpp

index 0e3105b510421329f1d99138f1cb068b59ca115d..debcfe67d9629408f477717a3c4639917dc96b82 100644 (file)
@@ -207,8 +207,8 @@ class ASTImporterTestBase : public ::testing::TestWithParam<ArgVector> {
 
   struct TU {
     // Buffer for the context, must live in the test scope.
-    StringRef Code;
-    StringRef FileName;
+    std::string Code;
+    std::string FileName;
     std::unique_ptr<ASTUnit> Unit;
     TranslationUnitDecl *TUDecl = nullptr;
     TU(StringRef Code, StringRef FileName, ArgVector Args)