This will make it easier to do things like `zig help | grep something`.
Invalid arguments will now display a short notice for `zig help`
instead of showing the full usage information. This will make it easier
to see the actual error.
I was looking at the tokenizer specifically fn testTokenize and the
this statement looked odd:
if (@TagType(Token.Id)(token.id) != @TagType(Token.Id)(expected_token_id)) {
I then saw the TODO and thought I'd remove StrLitKind figuring that
would make testTokenize simpler. It did so I thought I'd prepare this PR.
The tests are still working and stage2 zig seems to work, it compiles and
I was able to use the fmt command.
On Arch Linux the current default compiler is gcc 8.2.1 and this change
is needed to ignore the following errors:
In file included from /home/wink/local/include/llvm/ADT/STLExtras.h:21,
from /home/wink/local/include/llvm/ADT/StringRef.h:13,
from /home/wink/local/include/llvm/ADT/StringMap.h:17,
from /home/wink/local/include/llvm/Support/Host.h:17,
from /home/wink/local/include/llvm/ADT/Hashing.h:49,
from /home/wink/local/include/llvm/ADT/ArrayRef.h:13,
from /home/wink/local/include/llvm/ADT/APFloat.h:21,
from /home/wink/local/include/clang/AST/APValue.h:18,
from /home/wink/local/include/clang/AST/Decl.h:17,
from /home/wink/local/include/clang/AST/ASTTypeTraits.h:20,
from /home/wink/local/include/clang/AST/ASTContext.h:18,
from /home/wink/local/include/clang/Frontend/ASTUnit.h:18,
from /home/wink/prgs/ziglang/zig/src/translate_c.cpp:18:
/home/wink/local/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<void*, long unsigned int>]’:
/home/wink/local/include/llvm/Support/Allocator.h:249:33: required from ‘void* llvm::BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>::Allocate(size_t, size_t) [with AllocatorT = llvm::MallocAllocator; long unsigned int SlabSize = 4096; long unsigned int SizeThreshold = 4096; size_t = long unsigned int]’
/home/wink/local/include/clang/AST/ASTContext.h:659:42: required from here
/home/wink/local/include/llvm/ADT/SmallVector.h:313:11: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<void*, long unsigned int>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
memcpy(this->end(), &Elt, sizeof(T));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/utility:70,
from /home/wink/local/include/llvm/Support/type_traits.h:19,
from /home/wink/local/include/llvm/Support/Casting.h:19,
from /home/wink/local/include/clang/Basic/LLVM.h:22,
from /home/wink/local/include/clang/AST/APValue.h:17,
from /home/wink/local/include/clang/AST/Decl.h:17,
from /home/wink/local/include/clang/AST/ASTTypeTraits.h:20,
from /home/wink/local/include/clang/AST/ASTContext.h:18,
from /home/wink/local/include/clang/Frontend/ASTUnit.h:18,
from /home/wink/prgs/ziglang/zig/src/translate_c.cpp:18:
/usr/include/c++/8.2.1/bits/stl_pair.h:198:12: note: ‘struct std::pair<void*, long unsigned int>’ declared here
struct pair
^~~~
We were caching the ConstExprValue of string literals,
which works if you can never modify ConstExprValues.
This premise is broken with `comptime var ...`.
So I implemented an optimization in ConstExprValue
arrays, where it stores a `Buf *` directly rather
than an array of ConstExprValues for the elements,
and then similar to array of undefined, it is
expanded into the canonical form when necessary.
However many operations can happen directly on the
`Buf *`, which is faster.
Furthermore, before a ConstExprValue array is expanded
into canonical form, it removes itself from the string
literal cache. This fixes the issue, because before an
array element is modified it would have to be expanded.
closes#1076
from #llvm IRC:
<andrewrk> does llvm 7 as a .so have some kind of new initialization
requirement? I'm getting a segfault in llvm::DIBuilder::createFile
(with valid non-null parameters), when linking my frontend against
llvm-7.so but not when linking against llvm .a libraries
<d0k> we have an ABI bug in LLVM 7 when the .so is built with gcc
but your program is build with clang. I'm sorry for that.