LLVM how to set Attributes::NoUnwind to Function? - llvm

I think this is very simple question, but I can't resolve it. Very sad.
So. When I do
llc.exe -march=cpp test.bc
I get interesting test.cpp with this piece of code:
AttrListPtr func__Z2f1i_PAL;
{
SmallVector<AttributeWithIndex, 4> Attrs;
AttributeWithIndex PAWI;
PAWI.Index = 4294967295U; PAWI.Attrs = Attribute::None | Attribute::NoUnwind;
Attrs.push_back(PAWI);
func__Z2f1i_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
}
But when I want to write string like PAWI.Attrs = Attribute::None | Attribute::NoUnwind;
in my project, I got error IntelliSense: no operator "=" matches these operands operand types are: llvm::Attributes = int What I need to do?
All necessary headers included. [OS - Windows 7 x64, LLVM - 3.2]

I don't know why the cpp backend generates this code. In any case attribute handing was changed in 3.2 (and will change again in 3.3). The proper way to get an attribute in 3.2 should be:
Attributes::get(Context, Attributes::NoUnwind)
(you can always pass any ArrayRef here as the second argument, to initialize the attribute set with multiple values).
The simplest way to add an attribute to a function would be:
Function->addFnAttr(Attributes::NoUnwind)
And if you want an AttributeWithIndex:
AttributeWithIndex::get(Context, ID, Attributes::NoUnwind)
// OR:
AttributeWithIndex::get(ID, Attributes::get(Context, Attributes::NoUnwind))

Related

Making complex Terraform output optional?

I have an unenviable situation where I have to pass some unnecessary information into a module to make one thing (a Private Hosted R53 Zone), but not a bunch of others.
tl;dr, I'm trying to suppress outputs. If I didn't need to expose this output, my plan would behave as I expect. Outputs that produce strings or tuples were fine with me using the same condition to decide whether or not they would be evaluated, but the one below is still evaluating the attributes of the object:
output endpoint_dns_entries {
value = contains(local.de_dupe_phz_names, var.service["phz_name"]) ? {empty = [""]
emptyalso = [""]} : {
dns_names = aws_vpc_endpoint.endpoint.*.dns_entry[*].dns_name
hosted_zone_ids = aws_vpc_endpoint.endpoint.*.dns_entry[*].hosted_zone_id
}
}
yields errors:
Error: Unsupported attribute
on ../../endpoint-with-phz/outputs.tf line 12, in output "endpoint_dns_entries":
12: dns_names = aws_vpc_endpoint.endpoint.*.dns_entry[*].dns_name
This value does not have any attributes.
Error: Unsupported attribute
on ../../endpoint-with-phz/outputs.tf line 13, in output "endpoint_dns_entries":
13: hosted_zone_ids = aws_vpc_endpoint.endpoint.*.dns_entry[*].hosted_zone_id
This value does not have any attributes.
Any ideas on how to make this output optional?

Use a method on a StateNotifier Riverpod for changing a bool [duplicate]

In the context of a Flutter 2.0.5 app whose state I'd like to manage with Riverpod, I thought I can declare a StateNotifierProvider like this:
import 'package:flutter_riverpod/flutter_riverpod.dart';
final counterProvider = StateNotifierProvider<CounterStateNotifier>((ref) => CounterStateNotifier());
class CounterStateNotifier extends StateNotifier<int> {
CounterStateNotifier([int count = 0]) : super(count);
void increment() => state++;
}
But Android Studio (and later the Dart compiler as well) complains about the line where I declare the counterProvider variable:
The type 'StateNotifierProvider' is declared with 2 type parameters, but 1 type arguments were given.
Removing the <CounterStateNotifier> type parameter in StateNotifierProvider<CounterStateNotifier> removes the error. However, attempting to read the provider and call its increment method (setting () => context.read(counterProvider).increment() as the onPressed of an ElevatedButton, then pressing the button) gives the following runtime error:
'increment'
method not found
Receiver: 0
Arguments: []
Why is context.read(counterProvider) returning the int state instead of the notifier? And what is the reason behind the type parameter error mentioned in the first part of my question?
I should mention that I'm running my app on the web (with flutter run -d Chrome).
As of Riverpod 0.14.0, State is the default value exposed by StateNotifierProvider.
The syntax for declaring your StateNotifierProvider is now as follows:
final counterProvider = StateNotifierProvider<CounterStateNotifier, int>((ref) => CounterStateNotifier());
Accessing functions now requires adding .notifier (accessing the StateNotifier itself):
context.read(counterProvider.notifier).increment();
And like you've noticed, you now access the state like so:
final count = context.read(counterProvider);
More on the changes here.
You may also use dynamic to accept any type if value for the StateNotifierProvider
final modelProvider =
StateNotifierProvider.autoDispose<ModelClassName, dynamic>(
(ref) => ModelClassName());

How to pass multiple arguments to custom written Robot Framework Keyword?

Custom Keyword written in python 2.7:
#keyword("Update ${filename} with ${properties}")
def set_multiple_test_properties(self, filename, properties):
for each in values.split(","):
each = each.replace(" ", "")
key, value = each.split("=")
self.set_test_properties(filename, key, value)
When we send paremeters in a single line as shown below, its working as expected:
"Update sample.txt with "test.update=11,timeout=20,delay.seconds=10,maxUntouchedTime=10"
But when we modify the above line with a new lines (for better readability) it's not working.
Update sample.txt with "test.update = 11,
timeout=20,
delay.seconds=10,
maxUntouchedTime=10"
Any clue on this please?
I am not very sure whether it will work or not, but please try like this
Update sample.txt with "test.update = 11,
... timeout=20,
... delay.seconds=10,
... maxUntouchedTime=10"
Your approach is not working, cause the 2nd line is considered a call to a keyword (called "timeout=20,"), the 3rd another one, and so on. The 3 dots don't work cause they are "cell separators" - delimiter b/n arguments.
If you are going for readability, you can use the Catenate kw (it's in the Strings library):
${props}= Catenate SEPARATOR=${SPACE}
... test.update = 11,
... timeout=20,
... delay.seconds=10,
... maxUntouchedTime=10
, and then call your keyword with that variable:
Update sample.txt with "${props}"
btw, a) I think your keyword declaration in the decorator is without the double quotes - i.e. called like that ^ they'll be treated as part of the argument's value, b) there seems to be an error in the py method - the argument's name is "properties" while the itterator uses "values", and c) you might want to consider using named varargs (**kwargs in python, ${kwargs} in RF syntax) for this purpose (sorry, offtopic, but couldn't resist :)

Unable to add repeated field to protobuffer?

So I am attempting to add a repeated field to protobuff. However, whenever I generate the file using make, add_linkage does not take any arguements as if it's not actually able to read in the type that linkage is suppose to take (it's another protobuffer.) What am I doing wrong in the protobuffer file?
package model_velocity.msgs;
import "vector3d.proto";
message ModelVelResponse
{
required string name = 1;
required gazebo.msgs.Vector3d angularVel = 2;
required gazebo.msgs.Vector3d linearVel = 3;
}
message ModelVel_V{
repeated ModelVelResponse linkage = 1;
}
Do I need to do something different? Do I need to call a different function to repeat the message? Any help would be appreciated.
add_linkage() doesn't take any arguments. repeated message types' add_x() method return a pointer to a new, empty instance of the message. You need to do something like ModelVelResponse* resp = my_vodel_vel_v.add_linkage();. Then you can assign to the fields of the returned message as needed.

R: Countrycode package not supporting regex as the origin

I have a list of countries that i need to convert into standardized format (iso3c). Some have long names, others have 2 or 3 digit codes, and others do not display the whole country name like "Africa" instead of "South Africa". Ive done some research and come up to use countrycode package in R. However, when i tried to use "regex" R doesnt seem to recognize it. Im getting the error below:
> countrycode(data,"regex","iso3c", warn = TRUE)
Error in countrycode(data, "regex", "iso3c", :
Origin code not supported
Any other option I need to do?
Thanks!
You can view the README for the countrycode package here https://github.com/vincentarelbundock/countrycode, or you can pull up the help file in R by entering this into your R console ?countrycode::countrycode.
"regex" is not a valid 'origin' value (2nd argument in the countrycode() function). You must use one of "cowc", "cown", "eurostat", "fao", "fips105", "imf", "ioc", "iso2c", "iso3c", "iso3n", "p4_ccode", "p4_scode", "un", "wb", "wb_api2c", "wb_api3c", "wvs", "country.name", "country.name.de" (using latest version 0.19).
If you use either of the following 'origin' values, regex matching will be performed automatically: "country.name" or "country.name.de"
If you're using a custom dictionary with the new (as of version 0.19) custom_dict argument, you must set the origin_regex argument to TRUE for regex matching to occur.
In your example, this should do what you want:
countrycode(data, origin = "country.name", destination = "iso3c", warn = TRUE)