[Ada] Pretty-print attribute names using mixed case
authorDaniel Mercier <mercier@adacore.com>
Mon, 21 May 2018 14:52:31 +0000 (14:52 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 21 May 2018 14:52:31 +0000 (14:52 +0000)
2018-05-21  Daniel Mercier  <mercier@adacore.com>

gcc/ada/

* pprint.adb: Use mixed case for attribute names.

From-SVN: r260470

gcc/ada/ChangeLog
gcc/ada/pprint.adb

index a439064..1d5f079 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-04  Daniel Mercier  <mercier@adacore.com>
+
+       * pprint.adb: Use mixed case for attribute names.
+
 2018-04-04  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * sem_ch6.adb (Analyze_Generic_Subprogram_Body): Rename the call to
index 52ea018..e66de36 100644 (file)
@@ -24,6 +24,7 @@
 ------------------------------------------------------------------------------
 
 with Atree;   use Atree;
+with Csets;   use Csets;
 with Einfo;   use Einfo;
 with Namet;   use Namet;
 with Nlists;  use Nlists;
@@ -272,11 +273,35 @@ package body Pprint is
             when N_Attribute_Reference =>
                if Take_Prefix then
                   declare
+                     function To_Mixed_Case (S : String) return String;
+                     --  Transform given string into the corresponding one in
+                     --  mixed case form.
+
+                     function To_Mixed_Case (S : String) return String is
+                        Ucase  : Boolean := True;
+                        Result : String (S'Range);
+                     begin
+                        for J in S'Range loop
+                           if Ucase then
+                              Result (J) := Fold_Upper (S (J));
+                           else
+                              Result (J) := Fold_Lower (S (J));
+                           end if;
+
+                           Ucase := (S (J) = '_');
+                        end loop;
+
+                        return Result;
+                     end To_Mixed_Case;
+
                      Id     : constant Attribute_Id :=
                                 Get_Attribute_Id (Attribute_Name (Expr));
+
+                     --  Always use mixed case for attributes
                      Str    : constant String :=
                                 Expr_Name (Prefix (Expr)) & "'"
-                                  & Get_Name_String (Attribute_Name (Expr));
+                                  & To_Mixed_Case (Get_Name_String
+                                                      (Attribute_Name (Expr)));
                      N      : Node_Id;
                      Ranges : List_Id;