[PATCH] Knowledge of GCC attribtues

Richard Smith metafoo at gmail.com
Mon Jan 27 13:19:03 PST 2014

Looks great! It'd be nice for the 'isKnownToGCC' thing to look at the
spelling that was used, but that can wait (I don't think we have attributes
where it matters yet).

+class FlattenedSpelling {
+  std::string V, N, NS;
+  bool K;
+  FlattenedSpelling(const std::string &Variety, const std::string &Name,
+                    const std::string &Namespace, bool KnownToGCC) :
+    V(Variety), N(Name), NS(Namespace), K(KnownToGCC) {}
+  explicit FlattenedSpelling(const Record &Spelling) :
+    V(Spelling.getValueAsString("Variety")),
+    N(Spelling.getValueAsString("Name")) {

Maybe assert that V is not "GCC" here?

+    if (V == "CXX11")
+      NS = Spelling.getValueAsString("Namespace");
+    bool Unset;
+    K = Spelling.getValueAsBitOrUnset("KnownToGCC", Unset);
+  }
+  FlattenedSpelling(const FlattenedSpelling &RHS) : V(RHS.V), N(RHS.N),
+    NS(RHS.NS), K(RHS.K) {}
+  FlattenedSpelling& operator=(const FlattenedSpelling &RHS) {
+    if (&RHS != this) {
+      V = RHS.V;
+      N = RHS.N;
+      NS = RHS.NS;
+      K = RHS.K;
+    }
+    return *this;
+  }

Can you just use the implicit copy operations?

+  const std::string& Variety() const { return V; }
+  const std::string& Name() const { return N; }
+  const std::string& Namespace() const { return NS; }

& on the right, please, and start function names with lowercase.

+  bool KnownToGCC() const { return K; }

On Mon Jan 27 2014 at 10:36:48 AM, Aaron Ballman <aaron at aaronballman.com>

This patch is meant to replace one added by r199676. The goal of that
commit was to remove some specialness from thread safety attributes,
but as Richard had pointed out in IRC, there is a more correct
solution to be had: we need to encode knowledge of which attributes
are known to GCC. We already allow GNU-style attributes on function
definitions as an extension to GCC, which is what we were really
trying to (incompletely) encode with the thread-safety attribute

This patch adds a new meta-spelling called "GCC" -- it widens into
being a GNU spelling, and a CXX11 spelling with the namespace "gnu".
It also sets a bit on the spelling certifying that it is known to GCC.
>From this, we can warn about the extension appropriately. As a
consequence, the FunctionDefinition functionality is completely

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140127/a5db8c69/attachment.html>

More information about the cfe-commits mailing list