[llvm-bugs] [Bug 24425] New: Unexpected divergence between -fmodules and not (due to "<undeserialized declarations>"?)

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 10 20:48:19 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24425

            Bug ID: 24425
           Summary: Unexpected divergence between -fmodules and not (due
                    to "<undeserialized declarations>"?)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chisophugis at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Here's an example where -fmodules has an unexpected effect on the output. We
seem to not be deserializing some stuff.

a.cpp:
#include "a.h"                                                                  
// Modules version has Foo<int>::s_bar undefined.
// Nonmodules version has Foo<int>::s_bar defined.
template <typename T> char Foo<T>::s_bar;

a.h:
template <class T> struct Foo { static char s_bar; };
char baz() { return Foo<int>::s_bar; }

module.modulemap:
module a {                                                                      
  header "a.h"
}

repro.sh:
BIN=~/pg/d+a/bin                                                                
CLANGXX=$BIN/clang++
NM=$BIN/llvm-nm
CACHE_PATH=./cache_path

rm -rf $CACHE_PATH
$CLANGXX -c a.cpp -o a.o -fmodules-cache-path=$CACHE_PATH -fmodules && $NM a.o
| grep 's_bar'
$CLANGXX -c a.cpp -o a.o && $NM a.o | grep 's_bar'


Observed output on trunk:
% ./repro.sh
                 U __ZN3FooIiE5s_barE
0000000000000010 S __ZN3FooIiE5s_barE


Adding `-Xclang -ast-dump` to the compiler invocations in repro.sh suggests
that the issue is that we aren't deserializing `Foo<int>::s_bar`

(-fmodules)
...
|-ImportDecl 0x7f9b838394f8 <a.cpp:1:1> col:1 implicit a
|-VarDecl 0x7f9b84008058 parent 0x7f9b83839738 prev 0x7f9b84007fe8 <line:4:1,
col:36> col:36 s_bar 'char'
`-<undeserialized declarations>

(no -fmodules)
...
|-ClassTemplateDecl 0x7fc28883d910 <./a.h:1:1, col:52> col:27 Foo
| |-TemplateTypeParmDecl 0x7fc28883d7c8 <col:11, col:17> col:17 class T
| |-CXXRecordDecl 0x7fc28883d880 <col:20, col:52> col:27 struct Foo definition
| | |-CXXRecordDecl 0x7fc288885a00 <col:20, col:27> col:27 implicit struct Foo
| | `-VarDecl 0x7fc288885aa0 <col:33, col:45> col:45 s_bar 'char' static
| `-ClassTemplateSpecializationDecl 0x7fc288885c48 <col:1, col:52> col:27
struct Foo definition
|   |-TemplateArgument type 'int'
|   |-CXXRecordDecl 0x7fc288885e38 prev 0x7fc288885c48 <col:20, col:27> col:27
implicit struct Foo
|   `-VarDecl 0x7fc288885ec8 <col:33, col:45> col:45 used s_bar 'char' static
|-FunctionDecl 0x7fc288885b50 <line:2:1, col:38> col:6 baz 'char (void)'
| `-CompoundStmt 0x7fc288885fd0 <col:12, col:38>
|   `-ReturnStmt 0x7fc288885fb8 <col:14, col:31>
|     `-ImplicitCastExpr 0x7fc288885fa0 <col:21, col:31> 'char'
<LValueToRValue>
|       `-DeclRefExpr 0x7fc288885f68 <col:21, col:31> 'char' lvalue Var
0x7fc288885ec8 's_bar' 'char'
|-VarDecl 0x7fc288886280 parent 0x7fc28883d880 prev 0x7fc288885aa0 <a.cpp:4:1,
col:36> col:36 s_bar 'char'
`-VarDecl 0x7fc288886320 parent 0x7fc288885c48 prev 0x7fc288885ec8 <col:23,
col:36> col:36 used s_bar 'char'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150811/7f1b6cd3/attachment.html>


More information about the llvm-bugs mailing list