[PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0
Igor Chesnokov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 27 23:49:38 PST 2016
ichesnokov updated this revision to Diff 46229.
ichesnokov marked 2 inline comments as done.
http://reviews.llvm.org/D16351
Files:
lib/Sema/SemaDecl.cpp
test/SemaOpenCL/implicit-typedef.cl
tools/driver/driver.cpp
Index: tools/driver/driver.cpp
===================================================================
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -314,14 +314,34 @@
if (llvm::sys::Process::FixupStandardFileDescriptors())
return 1;
- SmallVector<const char *, 256> argv;
+ SmallVector<const char *, 256> _argv_;
llvm::SpecificBumpPtrAllocator<char> ArgAllocator;
std::error_code EC = llvm::sys::Process::GetArgumentVector(
- argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
+ _argv_, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
if (EC) {
llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
return 1;
}
+
+#if defined(_WINDOWS) && defined(_DEBUG)
+ // Sometimes when debugging in MSVC2015 some parameter(s) may end with "\n".
+ // The code below code removes wrong symbol.
+ std::vector<std::string> argvStorage;
+ SmallVector<const char *, 256> argv;
+ for (int I = 0, Count = _argv_.size(); I < Count; ++I) {
+ const char* P = _argv_[I];
+ size_t PLen = strlen(P);
+ if (PLen > 0 && P[PLen - 1] == '\n') {
+ std::string Reduced(P, 0, PLen - 1);
+ argvStorage.push_back(Reduced);
+ argv.push_back(argvStorage.back().c_str());
+ } else {
+ argv.push_back(P);
+ }
+ }
+#else
+ SmallVector<const char *, 256>& argv = _argv_;
+#endif
llvm::InitializeAllTargets();
std::string ProgName = argv[0];
Index: test/SemaOpenCL/implicit-typedef.cl
===================================================================
--- test/SemaOpenCL/implicit-typedef.cl
+++ test/SemaOpenCL/implicit-typedef.cl
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 "-cc1" "-emit-llvm" "-D" "cl_khr_fp64" "-D" "cl_khr_int64_base_atomics" "-fno-dwarf-directory-asm" "-fmessage-length" "205" "-fdiagnostics-show-option" "-cl-std=CL2.0" "-x" "cl" "%s" "-fcolor-diagnostics" -o -
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2033,6 +2033,12 @@
if (getLangOpts().Modules || getLangOpts().C11)
return;
+ // Added isImplicit() check, because implicit TypeDecl::getLocation()
+ // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag.
+ if (Old->isImplicit() || New->isImplicit()) {
+ return;
+ }
+
// If we have a redefinition of a typedef in C, emit a warning. This warning
// is normally mapped to an error, but can be controlled with
// -Wtypedef-redefinition. If either the original or the redefinition is
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16351.46229.patch
Type: text/x-patch
Size: 2612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160128/8a8ad23e/attachment-0001.bin>
More information about the cfe-commits
mailing list