[cfe-commits] r144379 - in /cfe/trunk: test/Misc/serialized-diags.c tools/libclang/CXLoadedDiagnostic.cpp
Ted Kremenek
kremenek at apple.com
Fri Nov 11 07:05:21 PST 2011
Hi Takumi,
I think we should instead fix CXLoadedDiagnosticSetImpl::makeString() to add a null terminator. Your patch actually introduces a memory leak since we don't ever explicitly release these CXStrings (and expect them to get released when the CXLoadedDiagnosticSetImpl object is destroyed).
Ted
On Nov 10, 2011, at 11:27 PM, NAKAMURA Takumi wrote:
> Author: chapuni
> Date: Fri Nov 11 01:27:33 2011
> New Revision: 144379
>
> URL: http://llvm.org/viewvc/llvm-project?rev=144379&view=rev
> Log:
> libclang/CXLoadedDiagnostic.cpp: Work around not to miss the string terminator on fixit.
>
> FixIts might be exposed as C string via clang_getCString(), though the zero terminator is not allocated in CXLoadedDiagnosticSetImpl::makeString.
>
> Modified:
> cfe/trunk/test/Misc/serialized-diags.c
> cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp
>
> Modified: cfe/trunk/test/Misc/serialized-diags.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags.c?rev=144379&r1=144378&r2=144379&view=diff
> ==============================================================================
> --- cfe/trunk/test/Misc/serialized-diags.c (original)
> +++ cfe/trunk/test/Misc/serialized-diags.c Fri Nov 11 01:27:33 2011
> @@ -18,6 +18,6 @@
> // CHECK: {{.*[/\\]}}serialized-diags.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
> // CHECK: Range: {{.*[/\\]}}serialized-diags.c:3:12 {{.*[/\\]}}serialized-diags.c:3:18
> // CHECK: +-{{.*[/\\]}}serialized-diags.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
> -// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0Parse Issueexpected ';' after expression"
> +// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0"
> // CHECK: {{.*[/\\]}}serialized-diags.c:8:22: error: expected ';' after expression []
> // CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.c:8:22 - {{.*[/\\]}}serialized-diags.c:8:22): ";"
>
> Modified: cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp?rev=144379&r1=144378&r2=144379&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp (original)
> +++ cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp Fri Nov 11 01:27:33 2011
> @@ -626,7 +626,7 @@
> llvm::StringRef RetStr;
> if (readString(TopDiags, RetStr, "FIXIT", Record, BlobStart, BlobLen))
> return Failure;
> - D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr, false)));
> + D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr)));
> continue;
> }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list