]> granicus.if.org Git - clang/commitdiff
Bug 7394 - Fixed toString representation of Precisions in format strings.
authorTom Care <tcare@apple.com>
Thu, 17 Jun 2010 22:55:40 +0000 (22:55 +0000)
committerTom Care <tcare@apple.com>
Thu, 17 Jun 2010 22:55:40 +0000 (22:55 +0000)
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106245 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Analyses/PrintfFormatString.h
lib/Analysis/PrintfFormatString.cpp

index 280c5baa6f6d152cb0e8e9c0c2268cdce32c3cba..79500bb1169c03993aa09720e55d88531f40199e 100644 (file)
@@ -192,11 +192,11 @@ public:
                  unsigned amountLength,
                  bool usesPositionalArg)
     : start(amountStart), length(amountLength), hs(howSpecified), amt(amount),
-      UsesPositionalArg(usesPositionalArg) {}
+      UsesPositionalArg(usesPositionalArg), UsesDotPrefix(0) {}
 
   OptionalAmount(bool valid = true)
     : start(0),length(0), hs(valid ? NotSpecified : Invalid), amt(0),
-      UsesPositionalArg(0) {}
+      UsesPositionalArg(0), UsesDotPrefix(0) {}
 
   bool isInvalid() const {
     return hs == Invalid;
@@ -236,12 +236,16 @@ public:
     return amt + 1;
   }
 
+  bool usesDotPrefix() const { return UsesDotPrefix; }
+  void setUsesDotPrefix() { UsesDotPrefix = true; }
+
 private:
   const char *start;
   unsigned length;
   HowSpecified hs;
   unsigned amt;
   bool UsesPositionalArg : 1;
+  bool UsesDotPrefix;
 };
 
 // Class representing optional flags with location and representation
@@ -362,6 +366,7 @@ public:
 
   void setPrecision(const OptionalAmount &Amt) {
     Precision = Amt;
+    Precision.setUsesDotPrefix();
   }
 
   const OptionalAmount &getPrecision() const {
index ba32e749a854b3480b4e12ea92a375b1e494bf9b..951be17e2f16f58ff7af0dd5ef75edf99366eff7 100644 (file)
@@ -611,6 +611,9 @@ const char *LengthModifier::toString() const {
 //===----------------------------------------------------------------------===//
 
 void OptionalAmount::toString(llvm::raw_ostream &os) const {
+  if (UsesDotPrefix)
+    os << ".";
+
   switch (hs) {
   case Invalid:
   case NotSpecified: