search for: static_cast

Displaying 20 results from an estimated 226 matches for "static_cast".

2015 May 07
2
[LLVMdev] Integer ID for LLVM::Instruction*?
David, As you suggested, I try to compile the following test code: *include "llvm/IR/Instruction.h"#include "stdint.h"extern void callback(intptr_t);void foo(){ llvm::Instruction* i; intptr_t zzzz=static_cast<intptr_t>(i); callback(zzzz);}* but got this compilation error: * 'intptr_t' (aka 'long') is not allowed intptr_t zzzz=static_cast<intptr_t>(i); ^~~~~~~~~~~~~~~~~~~~~~~~1 warning and 1 error generated.* For information, my OS is a Ubuntu 14.0...
2008 Dec 10
2
[LLVMdev] dyn_cast really doesn't like multiple inheritance
Been having a bit of a problem with dyn_cast: Suppose I have a class A that inherits from two base classes, both of which support dyn_cast. In order to use dyn_cast on A, I need to do a bunch of extra work: 1) Since dyn_cast uses reinterpret_cast rather than static_cast, the pointer value won't get adjusted by the cast operation, making the pointer invalid. I end up having to redefine "cast_convert_val" and other parts of the casting machinery for my type, so that it uses static_cast. 2) In every class B which derives from A, it seems like I hav...
2016 Dec 13
1
help needed: How to get during compile time the base class of casted C++ object inside static_cast<> and dynamic_cast<> and the pointer of the casted object
...but without using the compiler-rt. Caver and TypeSan: https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-lee.pdf https://nebelwelt.net/publications/files/16CCS2.pdf For example if I have the following C++ code snippet where I want to cast object b into object D. D* obj = static_cast<D*>(b); from where (inside Clang, LTO, thinLTO, etc.) can I get the base class of D and the base class ob b. Is this available in the Clang compiler or LTO? Also, if b is an object of a virtual Class (class with inherited or its own virtual functions) can I get its virtual pointer at compil...
2016 Dec 16
0
Help needed: How to get during compile time the base class of casted C++ object inside static_cast<> and dynamic_cast<> and the pointer of the casted object
...but without using the compiler-rt. Caver and TypeSan: https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-lee.pdf https://nebelwelt.net/publications/files/16CCS2.pdf For example if I have the following C++ code snippet where I want to cast object b into object D. D* obj = static_cast<D*>(b); from where (inside Clang, LTO, thinLTO, etc.) can I get the base class of D and the base class ob b. Is this available in the Clang compiler or LTO? Also, if b is an object of a virtual Class (class with inherited or its own virtual functions) can I get its virtual pointer at compil...
2016 Dec 21
2
*********How to get during compile time the base class of casted C++ object inside static_cast<> and dynamic_cast<> and the pointer of the casted object
...but without using the compiler-rt. Caver and TypeSan: https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-lee.pdf https://nebelwelt.net/publications/files/16CCS2.pdf For example if I have the following C++ code snippet where I want to cast object b into object D. D* obj = static_cast<D*>(b); from where (inside Clang, LTO, thinLTO, etc.) can I get the base class of D and the base class ob b. Is this available in the Clang compiler or LTO? Also, if b is an object of a virtual Class (class with inherited or its own virtual functions) can I get its virtual pointer at compil...
2012 Jun 19
0
[LLVMdev] llvm/include/Support/FileSystem.h
This is a proposed patch to enhance FileSystem.h to add functionality (getting and setting permission bits and mapping an unmapping files). This implementation follows the N3365 proposal regarding permission bits. This functionality is needed for my next patch which will implement llvm/include/Support/FileOutputBuffer.h which is needed by lld. -------------- next part -------------- A
2012 Mar 21
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...( item *result ) = 0; > }; > > I'm aware that LLVM doesn't know anything about C++ and that one way to call C++ functions is to wrap them in C thunks: > > extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result ) { > item_iterator *const that = static_cast<item_iterator*>( v_that ); > item *const result = static_cast<item*>( v_result ); > return that->next( result ); > } > > extern "C" void thunk_iterator_M_delete( void *v_that ) { > item_iterator *const that = static_cast<item_iterator*>(...
2012 Mar 15
3
[LLVMdev] Using JIT code to code a program to call C++
My project has a C++ library that I want to allow the user to use via some programming language to be JIT'd to call functions in said library. For the sake of simplicity, assume the library has classes like: class item { public: item(); item( int ); ~item(); // ... }; class item_iterator { public: virtual ~item_iterator(); virtual bool next( item *result ) = 0; };
2012 May 18
2
[LLVMdev] [RFC] llvm/include/Support/FileOutputBuffer.h
On Fri, May 18, 2012 at 3:07 PM, Michael Spencer <bigcheesegs at gmail.com> wrote: > >> +  error_code ec = sys::fs::status(filePathTwine, stat); > > stat is undefined if ec isn't success. ec will be success even in the case of > file_not_found. Actually I was wrong. The Windows and UNIX implementation disagree on this point. I'm going to change it to match
2013 Apr 10
2
[LLVMdev] Can't create "main" function?
I'm getting a strange behaviour when I attempt to create my main function: auto func = static_cast<llvm::Function*>(module->getOrInsertFunction( "main", types->type_void(), (llvm::Type*)0 ) ); ASSERT( func ); auto block = llvm::BasicBlock::Create( *context, "entry", func ); The "BasicBlock::Create" function is causing a segfault. This only happens if t...
2016 Nov 26
5
Placement new and TBAA
...the TBAA indeed. You don’t need the main and the union to reproduce, extracting foo() alone in its single own file is enough: void *operator new(decltype(sizeof 0), void *) noexcept; float *qq; void foo(int *p, int *q, long unk) { for (long i = 0; i < unk; ++i) { ++*p; qq = new (static_cast<void *>(&q[i])) float(42); } } LICM will get the store to p out of the loop, conceptually turning it into: void foo(int *p, int *q, long unk) { for (long i = 0; i < unk; ++i) { qq = new (static_cast<void *>(&q[i])) float(42); } ++*p; } Now I don’t know i...
2012 Mar 22
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...t;> }; >> >> I'm aware that LLVM doesn't know anything about C++ and that one way to call C++ functions is to wrap them in C thunks: >> >> extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result ) { >> item_iterator *const that = static_cast<item_iterator*>( v_that ); >> item *const result = static_cast<item*>( v_result ); >> return that->next( result ); >> } >> >> extern "C" void thunk_iterator_M_delete( void *v_that ) { >> item_iterator *const that = static_cast...
2005 Sep 02
2
DTX mode using preprocessor?
...STATUS returns 1) At the moment, I can hack around it by doing something like: if (VAD for prev frame && ! VAD for this frame) { iArg = 0; speex_encoder_ctl(m_esEncState,SPEEX_SET_VBR, &iArg); speex_encoder_ctl(m_esEncState,SPEEX_SET_QUALITY, &iArg); SBEncState *sbe = static_cast<SBEncState *>(m_esEncState); EncState *es = static_cast<EncState *>(sbe->st_low); es->dtx_count = 1; } (in wideband) .. which forces speex to send the DTX packet and the remote side knows it can safely ignore that stream for the time being -- the lack of packets is compl...
2013 Apr 10
0
[LLVMdev] Can't create "main" function?
Got it. I had a global_variable also with the name "main". Perhaps getOrInsertFuntion needs an assert to check this (it was returning a variable I guess rather than a function, and thus static_cast was broken). On 10/04/13 20:15, edA-qa mort-ora-y wrote: > I'm getting a strange behaviour when I attempt to create my main function: > > > auto func = static_cast<llvm::Function*>(module->getOrInsertFunction( > "main", > types->type_void(), (llvm::Ty...
2016 Dec 21
3
*********How to get during compile time the base class of casted C++ object inside static_cast<> and dynamic_cast<> and the pointer of the casted object
...//www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-lee.pdf >> https://nebelwelt.net/publications/files/16CCS2.pdf >> >> For example if I have the following C++ code snippet where I want to >> cast object b into >> object D. >> >> D* obj = static_cast<D*>(b); >> >> from where (inside Clang, LTO, thinLTO, etc.) can I get the base class >> of D and the base class ob b. Is this >> available in the Clang compiler or LTO? >> >> Also, if b is an object of a virtual Class (class with inherited or its >> o...
2016 Dec 21
0
*********How to get during compile time the base class of casted C++ object inside static_cast<> and dynamic_cast<> and the pointer of the casted object
...r and TypeSan: > https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-lee.pdf > https://nebelwelt.net/publications/files/16CCS2.pdf > > For example if I have the following C++ code snippet where I want to > cast object b into > object D. > > D* obj = static_cast<D*>(b); > > from where (inside Clang, LTO, thinLTO, etc.) can I get the base class > of D and the base class ob b. Is this > available in the Clang compiler or LTO? > > Also, if b is an object of a virtual Class (class with inherited or its > own virtual functions) can...
2013 Apr 11
1
[LLVMdev] Can't create "main" function?
Hi, On 10/04/13 20:23, edA-qa mort-ora-y wrote: > Got it. I had a global_variable also with the name "main". Perhaps > getOrInsertFuntion needs an assert to check this (it was returning a > variable I guess rather than a function, and thus static_cast was broken). if you use LLVM's cast rather than static_cast then you will get an assertion failure if the cast is wrong. Ciao, Duncan. > > On 10/04/13 20:15, edA-qa mort-ora-y wrote: >> I'm getting a strange behaviour when I attempt to create my main function: >> >&g...
2019 Aug 01
5
RFC: Strong typedef for LLVM
...d::move(V)) {} public: explicit operator BaseType&() noexcept { return Value; } explicit operator const BaseType&() const noexcept { return Value; } friend void swap(StrongTypedef &A, StrongTypedef &B) noexcept { using std::swap; swap(static_cast<BaseType&>(A), static_cast<BaseType&>(B)); } }; class Flag1Value : public StrongTypedef<Flag1Value, bool> { public: using StrongTypedef::StrongTypedef; }; class Flag2Value : public StrongTypedef<Flag2Value, bool> { public: using StrongTypede...
2016 Dec 21
0
*********How to get during compile time the base class of casted C++ object inside static_cast<> and dynamic_cast<> and the pointer of the casted object
...https://nebelwelt.net/publications/files/16CCS2.pdf <https://nebelwelt.net/publications/files/16CCS2.pdf> >>> >>> For example if I have the following C++ code snippet where I want to >>> cast object b into >>> object D. >>> >>> D* obj = static_cast<D*>(b); >>> >>> from where (inside Clang, LTO, thinLTO, etc.) can I get the base class >>> of D and the base class ob b. Is this >>> available in the Clang compiler or LTO? >>> >>> Also, if b is an object of a virtual Class (class with i...
2009 May 13
2
[LLVMdev] Compiler error: LoopStrengthReduce.cpp
...through it closely later >> and report more. >> >> So, for now, just keep using (int) in my version until it is fixed >> in trunk? > > I checked in a fix. Also, IndVarSimplify.cpp has the same problem, only one abs usage in it, line 700: if (Max.getZExtValue() > static_cast<uint64_t>(abs(intEV - intIV))) Following your style change: if (Max.getZExtValue() > static_cast<uint64_t>(abs64(intEV - intIV))) Also, why make an abs64, why not just override abs with 64 bit parameters?