X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FCodingStandards.html;h=44a55a55857548133d99fa24c2cd8346a65dda72;hb=221b239342d6089550ad7f49cbf49509111d3f7e;hp=e3ec3ff136c743d56004cd64bd867c7d83714a1e;hpb=18d52f2fb551c295bbce4c7d7357f4050b06e926;p=oota-llvm.git diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index e3ec3ff136c..44a55a55857 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -397,9 +397,10 @@ portable code. If there are cases where it isn't possible to write portable code, isolate it behind a well defined (and well documented) interface.

In practice, this means that you shouldn't assume much about the host -compiler, including its support for "high tech" features like partial -specialization of templates. If these features are used, they should only be -an implementation detail of a library which has a simple exposed API.

+compiler, and Visual Studio tends to be the lowest common denominator. +If advanced features are used, they should only be an implementation detail of +a library which has a simple exposed API, and preferably be buried in +libSystem.

@@ -851,6 +852,38 @@ return 0; +

Another issue is that values used only by assertions will produce an "unused + value" warning when assertions are disabled. For example, this code will warn: +

+ +
+
+  unsigned Size = V.size(); 
+  assert(Size > 42 && "Vector smaller than it should be");
+
+  bool NewToSet = Myset.insert(Value);
+  assert(NewToSet && "The value shouldn't be in the set yet");  
+
+
+ +

These are two interesting different cases: in the first case, the call to +V.size() is only useful for the assert, and we don't want it executed when +assertions are disabled. Code like this should move the call into the assert +itself. In the second case, the side effects of the call must happen whether +the assert is enabled or not. In this case, the value should be cast to void +to disable the warning. To be specific, it is preferred to write the code +like this:

+ +
+
+  assert(V.size() > 42 && "Vector smaller than it should be");
+
+  bool NewToSet = Myset.insert(Value); (void)NewToSet;
+  assert(NewToSet && "The value shouldn't be in the set yet");  
+
+
+ +