[llvm-bugs] [Bug 25683] New: Incorrect source location on out-of-line defaulted constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 30 14:48:48 PST 2015


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

            Bug ID: 25683
           Summary: Incorrect source location on out-of-line defaulted
                    constructor
           Product: clang
           Version: 3.7
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: trprince at synopsys.com
                CC: llvm-bugs at lists.llvm.org, sig-clang-bugs at synopsys.com
    Classification: Unclassified

The following snippet produces an AST in which the starting source location
appears *after* the end location:

> $ cat bad.cpp
> template <typename> struct s { s(); };
> s<int> a;
> template <typename T> s<T>::s() = default;
> $ clang -v -std=c++11 -Xclang -ast-dump -fsyntax-only bad.cpp
> clang version 3.7.0 (tags/RELEASE_370/final)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
> Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
> Candidate multilib: .;@m64
> Candidate multilib: 32;@m32
> Selected multilib: .;@m64
>  "/opt/pkg/clang-3.7.0/bin/clang-3.7" -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -main-file-name bad.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -resource-dir /opt/pkg/clang-3.7.0/bin/../lib/clang/3.7.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/backward -internal-isystem /usr/local/include -internal-isystem /opt/pkg/clang-3.7.0/bin/../lib/clang/3.7.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /slowfs/sighome/trprince/lab/bz82561 -ferror-limit 19 -fmessage-length 211 -mstack
 realign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -ast-dump -x c++ bad.cpp
> clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-unknown-linux-gnu
> ignoring nonexistent directory "/include"
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6
>  /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu
>  /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/backward
>  /usr/local/include
>  /opt/pkg/clang-3.7.0/bin/../lib/clang/3.7.0/include
>  /usr/include/x86_64-linux-gnu
>  /usr/include
> End of search list.
> TranslationUnitDecl 0x86c6510 <<invalid sloc>> <invalid sloc>
> |-TypedefDecl 0x86c6a48 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
> |-TypedefDecl 0x86c6aa8 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
> |-TypedefDecl 0x86c6e88 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list '__va_list_tag [1]'
> |-ClassTemplateDecl 0x86c7020 <bad.cpp:1:1, col:37> col:28 s
> | |-TemplateTypeParmDecl 0x86c6ed8 <col:11> col:11 typename
> | |-CXXRecordDecl 0x86c6f90 <col:21, col:37> col:28 struct s definition
> | | |-CXXRecordDecl 0x870f060 <col:21, col:28> col:28 implicit referenced struct s
> | | `-CXXConstructorDecl 0x870f190 <col:32, col:34> col:32 s<type-parameter-0-0> 'void (void)'
> | `-ClassTemplateSpecializationDecl 0x870f260 <col:1, col:37> col:28 struct s definition
> |   |-TemplateArgument type 'int'
> |   |-CXXRecordDecl 0x870f508 prev 0x870f260 <col:21, col:28> col:28 implicit struct s
> |   |-CXXConstructorDecl 0x870f5d8 <line:3:23, line:1:32> col:32 used constexpr s 'void (void) noexcept'
> |   | `-CompoundStmt 0x870feb0 <col:32>
> |   |-CXXConstructorDecl 0x870f6d8 <col:28> col:28 implicit constexpr s 'void (const struct s<int> &)' inline noexcept-unevaluated 0x870f6d8
> |   | `-ParmVarDecl 0x870f820 <col:28> col:28 'const struct s<int> &'
> |   `-CXXConstructorDecl 0x870f8b8 <col:28> col:28 implicit constexpr s 'void (struct s<int> &&)' inline noexcept-unevaluated 0x870f8b8
> |     `-ParmVarDecl 0x870fa00 <col:28> col:28 'struct s<int> &&'
> |-VarDecl 0x870f408 <line:2:1, col:8> col:8 a 's<int>':'struct s<int>' callinit
> | `-CXXConstructExpr 0x870fa68 <col:8> 's<int>':'struct s<int>' 'void (void) noexcept'
> `-CXXConstructorDecl 0x870fd40 parent 0x86c6f90 prev 0x870f190 <line:3:1, col:31> col:29 s<type-parameter-0-0> 'void (void)'
> $ 

In particular, note the line numbers on the second CXXConstructorDecl:
> CXXConstructorDecl 0x870f5d8 <line:3:23, line:1:32>

This doesn't seem to cause any problems in clang proper, but passing this range
to clang::PreprocessingRecord::getPreprocessedEntitiesInRange triggers an
assertion, since the start of the range occurs after the end.

-- 
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/20151130/91dfb590/attachment.html>


More information about the llvm-bugs mailing list