]> granicus.if.org Git - clang/commit
[OpenCL] Fix serialization of OpenCLExtensionDecls
authorAndrew Savonichev <andrew.savonichev@intel.com>
Mon, 29 Oct 2018 11:14:01 +0000 (11:14 +0000)
committerAndrew Savonichev <andrew.savonichev@intel.com>
Mon, 29 Oct 2018 11:14:01 +0000 (11:14 +0000)
commitec426d1675196956d30e556601c5878ef5b04f63
tree44c385343da6f523c8087a4258fd9f6be387f272
parentbab1e4efc5783c45d8c6a6850e94a00deb378984
[OpenCL] Fix serialization of OpenCLExtensionDecls

Summary:
I recently discovered that adding the following code into `opencl-c.h` causes
failure of `test/Headers/opencl-c-header.cl`:
```
#pragma OPENCL EXTENSION cl_my_ext : begin
void cl_my_ext_foobarbaz();
#pragma OPENCL EXTENSIOn cl_my_ext : end
```

Clang crashes at the assertion is `ASTReader::getGlobalSubmoduleID()`:
```
assert(I != M.SubmoduleRemap.end() && "Invalid index into submodule index remap");
```

The root cause of the problem that to deserialize `OPENCL_EXTENSION_DECLS`
section `ASTReader` needs to deserialize a Decl contained in it. In turn,
deserializing a Decl requires information about whether this declaration is
part of a (sub)module, but this information is not read yet because it is
located further in a module file.

Reviewers: Anastasia, yaxunl, JDevlieghere

Reviewed By: Anastasia

Subscribers: sidorovd, cfe-commits, asavonic

Differential Revision: https://reviews.llvm.org/D53200

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345497 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Serialization/ASTWriter.cpp
test/SemaOpenCL/extension-begin.cl
test/SemaOpenCL/extension-begin.h [new file with mode: 0644]