r332256 - [ASTImporter] Turn StringRefs back to std::strings to avoid use-after-free

Aleksei Sidorin via cfe-commits cfe-commits at lists.llvm.org
Mon May 14 09:12:31 PDT 2018


Author: a.sidorin
Date: Mon May 14 09:12:31 2018
New Revision: 332256

URL: http://llvm.org/viewvc/llvm-project?rev=332256&view=rev
Log:
[ASTImporter] Turn StringRefs back to std::strings to avoid use-after-free

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().


Modified:
    cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=332256&r1=332255&r2=332256&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon May 14 09:12:31 2018
@@ -207,8 +207,8 @@ class ASTImporterTestBase : public ::tes
 
   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)




More information about the cfe-commits mailing list