how to add a ModulePassManager in llvm pass? - clang

I'm trying to add a ModulePassManager in llvm pass, because all pass is function pass, so all I added createModuleToFunctionPassAdaptor function, but compile error, I don't know how to solve it. does anybody know how to solve this problem. I tried this:
llvm::PreservedAnalyses DBogusFlow::run(llvm::Module &M,
llvm::ModuleAnalysisManager &MAM) {
bool Changed = runOnModule(M);
auto MPM = std::make_unique<ModulePassManager>();
MPM->addPass(createModuleToFunctionPassAdaptor(createAggressiveDCEPass()));
MPM->addPass(
createModuleToFunctionPassAdaptor(createInstructionCombiningPass()));
MPM->addPass(
createModuleToFunctionPassAdaptor(createCFGSimplificationPass()));
MPM->run(M, MAM);
return (Changed ? llvm::PreservedAnalyses::none()
: llvm::PreservedAnalyses::all());
}
below is the compile error
[ 50%] Building CXX object CMakeFiles/DBogusFlow.dir/lib/DBogusFlow.cpp.o
In file included from /usr/include/llvm/IR/PassManager.h:48,
from /home/v4kst1z/Desktop/ollvm-deobfuscator/lib/../include/DBogusFlow.h:12,
from /home/v4kst1z/Desktop/ollvm-deobfuscator/lib/DBogusFlow.cpp:9:
/usr/include/llvm/IR/PassManagerInternal.h: In instantiation of ‘PreservedAnalysesT llvm::detail::PassModel<IRUnitT, PassT, PreservedAnalysesT, AnalysisManagerT, ExtraArgTs>::run(IRUnitT&, AnalysisManagerT&, ExtraArgTs ...) [with IRUnitT = llvm::Function; PassT = llvm::FunctionPass*; PreservedAnalysesT = llvm::PreservedAnalyses; AnalysisManagerT = llvm::AnalysisManager<llvm::Function>; ExtraArgTs = {}]’:
/usr/include/llvm/IR/PassManagerInternal.h:83:22: required from here
/usr/include/llvm/IR/PassManagerInternal.h:85:17: error: request for member ‘run’ in ‘((llvm::detail::PassModel<llvm::Function, llvm::FunctionPass*, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >*)this)->llvm::detail::PassModel<llvm::Function, llvm::FunctionPass*, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::Pass’, which is of pointer type ‘llvm::FunctionPass*’ (maybe you meant to use ‘->’ ?)
85 | return Pass.run(IR, AM, ExtraArgs...);
| ~~~~~^~~
/usr/include/llvm/IR/PassManagerInternal.h: In instantiation of ‘llvm::StringRef llvm::detail::PassModel<IRUnitT, PassT, PreservedAnalysesT, AnalysisManagerT, ExtraArgTs>::name() const [with IRUnitT = llvm::Function; PassT = llvm::FunctionPass*; PreservedAnalysesT = llvm::PreservedAnalyses; AnalysisManagerT = llvm::AnalysisManager<llvm::Function>; ExtraArgTs = {}]’:
/usr/include/llvm/IR/PassManagerInternal.h:88:13: required from here
/usr/include/llvm/IR/PassManagerInternal.h:88:55: error: ‘name’ is not a member of ‘llvm::FunctionPass*’
88 | StringRef name() const override { return PassT::name(); }
| ~~~~~~~~~~~^~
make[2]: *** [CMakeFiles/DBogusFlow.dir/build.make:76: CMakeFiles/DBogusFlow.dir/lib/DBogusFlow.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/DBogusFlow.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Related

Dart: Constant evaluation error. The method '[]' can't be invoked in a constant expression

I am getting an error on constant evaluation.
please take a look at this code:
class A {
final num a;
const A(this.a);
}
class B {
final A a;
const B(this.a);
}
main() {
const a = A(12);
const b = B(a); // this works fine
// I believe everything inside a const List is considered constant,
// please correct me if that is wrong
const aL = [ A(12), A(13) ]; // [ a, A(13) ] will not work either
const b2 = B(
aL[0], // here the error is happening
);
}
Error:
lib/logic/dartTest.dart:22:14: Error: Constant evaluation error:
const b2 = B(
^
lib/logic/dartTest.dart:23:7: Context: The method '[]' can't be invoked on '<A>[A {a: 12}, A {a: 13}]' in a constant expression. - 'A' is from 'package:t_angband/logic/dartTest.dart' ('lib/logic/dartTest.dart').
aL[0],
^
lib/logic/dartTest.dart:22:9: Context: While analyzing:
const b2 = B(
^
The list contains constant Object, then why the constant evaluation is failing? Shouldn't this be an analyzer issue? Am I missing something?
Thankyou.
Constant expressions can only build data, it cannot deconstruct it. You cannot call any methods on the constant objects except a handful of operations on numbers (and String.length, which also creates a number).
So, aL[0] is simply not a valid compile-time constant expression.
A possible fix may be to make b2 not constant!

`url_serde` asking for unrelated trait bounds

Using the serde and url_serde crates, I get errors suggesting I need to fulfill unrelated trait bounds:
Compiling ser v0.1.0 (/data/scratch/ser)
error[E0277]: the trait bound `for<'a> url_serde::Ser<'a, url::Url>: a::_::_serde::Serialize` is not satisfied
--> src/b.rs:4:10
|
4 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^ the trait `for<'a> a::_::_serde::Serialize` is not implemented for `url_serde::Ser<'a, url::Url>`
|
::: /home/danj/.cargo/registry/src/github.com-1ecc6299db9ec823/url_serde-0.2.0/src/lib.rs:77:46
|
77 | where S: Serializer, for<'a> Ser<'a, T>: Serialize
| --------- required by this bound in `url_serde::serialize`
|
= help: the following implementations were found:
<url_serde::Ser<'a, std::option::Option<url::Url>> as a::_::_serde::Serialize>
<url_serde::Ser<'a, url::Url> as a::_::_serde::Serialize>
<url_serde::Ser<'a, url::host::Host<String>> as a::_::_serde::Serialize>
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `url_serde::De<url::Url>: a::_::_serde::Deserialize<'_>` is not satisfied
--> src/b.rs:4:21
|
4 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^^^ the trait `a::_::_serde::Deserialize<'_>` is not implemented for `url_serde::De<url::Url>`
|
::: /home/danj/.cargo/registry/src/github.com-1ecc6299db9ec823/url_serde-0.2.0/src/lib.rs:158:40
|
158 | where D: Deserializer<'de>, De<T>: Deserialize<'de>
| ---------------- required by this bound in `url_serde::deserialize`
|
= help: the following implementations were found:
<url_serde::De<std::option::Option<url::Url>> as a::_::_serde::Deserialize<'de>>
<url_serde::De<url::Url> as a::_::_serde::Deserialize<'de>>
<url_serde::De<url::host::Host> as a::_::_serde::Deserialize<'de>>
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `ser`.
To learn more, run the command again with --verbose.
Cargo.toml
[package]
name = "ser"
version = "0.1.0"
authors = ["..."]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.115", features = ["derive"] }
url = "2.1.1"
url_serde = "0.2.0"
src/lib.rs:
pub mod a;
pub mod b;
src/a.rs:
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct A {
pub name: String,
}
src/b.rs:
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Serialize, Deserialize)]
pub struct B {
#[serde(with = "url_serde")]
uri: Url,
}
Found this through crates.io linking to an upgrade: https://github.com/servo/rust-url/blob/b03895bd479d72c75600dc09c8c7906f5ee203ea/UPGRADING.md
tl;dr
url = { version = "2.0", features = ["serde"] }
and remove all references to url_serde

Error: invalid initialization of non-const reference of type ‘const RTT::corba::CConnPolicy*&’

I'm trying build the package orocos-toolchain from source.I have already build the ace and tao package inside ACE_wrapper which i downloaded from this page. But after i enter command" catkin_make_isolated --install -DENABLE_CORBA=ON -DCORBA_IMPLEMENTATION=TAO " I'm getting below error:
[100%] Building CXX object rtt/transports/corba/CMakeFiles/rtt-transport-corba-gnulinux_plugin.dir/CorbaLib.cpp.o
In file included from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaLib.cpp:50:0:
/home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/RTTCorbaConversion.hpp: In static member function ‘static bool RTT::corba::AnyConversion<RTT::ConnPolicy>::update(const CORBA::Any&, RTT::corba::AnyConversion<RTT::ConnPolicy>::StdType&)’:
/home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/RTTCorbaConversion.hpp:313:18: error: invalid initialization of non-const reference of type ‘const RTT::corba::CConnPolicy*&’ from an rvalue of type ‘const RTT::corba::CConnPolicy*’
if ( any >>= result ) {
^
In file included from /home/dinesh/ws/underlay_isolated/build_isolated/rtt/install/rtt/transports/corba/ServiceC.h:114:0,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaTypeTransporter.hpp:44,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaTemplateProtocol.hpp:42,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaLib.cpp:49:
/home/dinesh/ws/underlay_isolated/build_isolated/rtt/install/rtt/transports/corba/DataFlowC.h:1320:32: note: initializing argument 2 of ‘CORBA::Boolean operator>>=(const CORBA::Any&, const RTT::corba::CConnPolicy*&)’
RTT_CORBA_API ::CORBA::Boolean operator>>= (const ::CORBA::Any &, const RTT::corba::CConnPolicy *&);
^
In file included from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/DataFlowI.h:47:0,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/RemoteChannelElement.hpp:42,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaTemplateProtocol.hpp:43,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaLib.cpp:49:
/home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaConversion.hpp: In instantiation of ‘static bool RTT::corba::AnyConversion<std::vector<_Tp, _Alloc> >::update(const CORBA::Any&, RTT::corba::AnyConversion<std::vector<_Tp, _Alloc> >::StdType&) [with T = double; _Alloc = std::allocator<double>; RTT::corba::AnyConversion<std::vector<_Tp, _Alloc> >::StdType = std::vector<double>]’:
/home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaTemplateProtocol.hpp:118:57: required from ‘bool RTT::corba::CorbaTemplateProtocol<T>::updateFromAny(const CORBA::Any*, RTT::base::DataSourceBase::shared_ptr) const [with T = std::vector<double>; RTT::base::DataSourceBase::shared_ptr = boost::intrusive_ptr<RTT::base::DataSourceBase>]’
/home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaLib.cpp:208:1: required from here
/home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaConversion.hpp:259:18: error: invalid initialization of non-const reference of type ‘const CORBA::DoubleSeq*&’ from an rvalue of type ‘const CORBA::DoubleSeq*’
if ( any >>= result ) {
^
In file included from /home/dinesh/ws/underlay_isolated/build_isolated/rtt/install/rtt/transports/corba/ServiceC.h:51:0,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaTypeTransporter.hpp:44,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaTemplateProtocol.hpp:42,
from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaLib.cpp:49:
/home/dinesh/ACE_wrappers/TAO/tao/AnyTypeCode/DoubleSeqA.h:86:41: note: initializing argument 2 of ‘CORBA::Boolean operator>>=(const CORBA::Any&, const CORBA::DoubleSeq*&)’
TAO_AnyTypeCode_Export ::CORBA::Boolean operator>>= (const ::CORBA::Any &, const CORBA::DoubleSeq *&);
^
In file included from /home/dinesh/ws/underlay_isolated/src/orocos/orocos_toolchain/rtt/rtt/transports/corba/CorbaLib.cpp:42:0:
/home/dinesh/ACE_wrappers/TAO/tao/PortableServer/PortableServer.h: At global scope:
/home/dinesh/ACE_wrappers/TAO/tao/PortableServer/PortableServer.h:34:1: warning: ‘TAO_Requires_POA_Initializer’ defined but not used [-Wunused-variable]
TAO_Requires_POA_Initializer = TAO_POA_Initializer::init ();
^
rtt/transports/corba/CMakeFiles/rtt-transport-corba-gnulinux_plugin.dir/build.make:62: recipe for target 'rtt/transports/corba/CMakeFiles/rtt-transport-corba-gnulinux_plugin.dir/CorbaLib.cpp.o' failed
make[2]: *** [rtt/transports/corba/CMakeFiles/rtt-transport-corba-gnulinux_plugin.dir/CorbaLib.cpp.o] Error 1
CMakeFiles/Makefile2:935: recipe for target 'rtt/transports/corba/CMakeFiles/rtt-transport-corba-gnulinux_plugin.dir/all' failed
make[1]: *** [rtt/transports/corba/CMakeFiles/rtt-transport-corba-gnulinux_plugin.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
<== Failed to process package 'rtt':
Command '['/home/dinesh/ws/underlay_isolated/install_isolated/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2
Reproduce this error by running:
==> cd /home/dinesh/ws/underlay_isolated/build_isolated/rtt && /home/dinesh/ws/underlay_isolated/install_isolated/env.sh make -j4 -l4
Command failed, exiting.
Try to change CorbaType* result; to const CorbaType* result; on line 259 of rtt/rtt/transports/corba/CorbaConversion.hpp

Im Getting Errors From Terminal About My Code

I have almost finished my code, but terminal is giving me the following errors:
Tweak.xm:149:15: error: unused variable 'settings' [-Werror,-Wunused-variable]
NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:#"...
^
Tweak.xm:152:1: error: expected unqualified-id
if (settings) {
^
Tweak.xm:156:1: error: expected unqualified-id
if (lsSame) {
^
3 errors generated.
make[2]: *** [obj/Tweak.xm.c8cb265e.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [CustomColr.all.tweak.variables] Error 2
Here is my code:
http://pastie.org/10076062

How to mark as deprecated a single enum value in Delphi

I wish to have the following:
TEnumType = (
etValue1 = 1,
etValue2 = 2 deprecated,
etValue3 = 3);
It returns:
[DCC Error] unt_CollectionImportType.pas(19): E2029 ',' or ')' expected
but identifier 'deprecated' found.
Is there a way to instruct the compiler that this value is deprecated.
type
TEnumType = (
etValue1 = 1,
etDeprecated2 = 2, // was: etValue2; Renamed so we can deprecate it by name
etValue3 = 3);
const
etValue2 = etDeprecated2 deprecated; // Declares a constant mapped to the renamed enum value.

Resources