[cfe-commits] r38717 - in /cfe/cfe/trunk: Lex/MacroExpander.cpp Lex/Preprocessor.cpp include/clang/Basic/DiagnosticKinds.def

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:24:04 PDT 2007


Author: sabre
Date: Wed Jul 11 11:24:03 2007
New Revision: 38717

URL: http://llvm.org/viewvc/llvm-project?rev=38717&view=rev
Log:
More changes from formals -> actuals.

Modified:
    cfe/cfe/trunk/Lex/MacroExpander.cpp
    cfe/cfe/trunk/Lex/Preprocessor.cpp
    cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def

Modified: cfe/cfe/trunk/Lex/MacroExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/MacroExpander.cpp?rev=38717&r1=38716&r2=38717&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/MacroExpander.cpp (original)
+++ cfe/cfe/trunk/Lex/MacroExpander.cpp Wed Jul 11 11:24:03 2007
@@ -65,7 +65,7 @@
 
   // Stringify all the tokens.
   std::string Result = "\"";
-  for (unsigned i = 0, e = Toks.size(); i != e; ++i) {
+  for (unsigned i = 0, e = Toks.size()-1 /*no eof*/; i != e; ++i) {
     const LexerToken &Tok = Toks[i];
     // FIXME: Optimize this.
     if (i != 0 && Tok.hasLeadingSpace())
@@ -108,9 +108,7 @@
     
     // Check for bogus character.
     bool isBad = false;
-    if (Result.size() == 2) {
-      Result = "' '";            // #@empty -> ' '.
-    } else if (Result.size() == 3) {
+    if (Result.size() == 3) {
       isBad = Result[1] == '\'';   // ''' is not legal. '\' already fixed above.
     } else {
       isBad = (Result.size() != 4 || Result[1] != '\\');  // Not '\x'
@@ -132,14 +130,14 @@
 /// that has been 'stringified' as required by the # operator.
 const LexerToken &MacroArgs::getStringifiedArgument(unsigned ArgNo,
                                                     Preprocessor &PP) {
-  assert(ArgNo < ExpArgTokens.size() && "Invalid argument number!");
+  assert(ArgNo < UnexpArgTokens.size() && "Invalid argument number!");
   if (StringifiedArgs.empty()) {
-    StringifiedArgs.resize(ExpArgTokens.size());
+    StringifiedArgs.resize(getNumArguments());
     memset(&StringifiedArgs[0], 0,
            sizeof(StringifiedArgs[0])*getNumArguments());
   }
   if (StringifiedArgs[ArgNo].getKind() != tok::string_literal)
-    StringifiedArgs[ArgNo] = StringifyArgument(ExpArgTokens[ArgNo], PP);
+    StringifiedArgs[ArgNo] = StringifyArgument(UnexpArgTokens[ArgNo], PP);
   return StringifiedArgs[ArgNo];
 }
 

Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=38717&r1=38716&r2=38717&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:24:03 2007
@@ -602,7 +602,7 @@
   // If this macro expands to no tokens, don't bother to push it onto the
   // expansion stack, only to take it right back off.
   if (MI->getNumTokens() == 0) {
-    // No need for formal arg info.
+    // No need for arg info.
     delete Args;
     
     // Ignore this macro use, just return the next token in the current
@@ -666,7 +666,7 @@
 }
 
 /// ReadFunctionLikeMacroArgs - After reading "MACRO(", this method is
-/// invoked to read all of the formal arguments specified for the macro
+/// invoked to read all of the actual arguments specified for the macro
 /// invocation.  This returns null on error.
 MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName,
                                                    MacroInfo *MI) {
@@ -679,7 +679,7 @@
   bool isVariadic = MI->isVariadic();
   
   // If this is a C99-style varargs macro invocation, add an extra expected
-  // argument, which will catch all of the varargs formals in one argument.
+  // argument, which will catch all of the vararg args in one argument.
   if (MI->isC99Varargs())
     ++NumFixedArgsLeft;
   
@@ -715,11 +715,11 @@
         if (NumFixedArgsLeft)
           break;
         
-        // If this is not a variadic macro, too many formals were specified.
+        // If this is not a variadic macro, too many args were specified.
         if (!isVariadic) {
           // Emit the diagnostic at the macro name in case there is a missing ).
           // Emitting it at the , could be far away from the macro name.
-          Diag(MacroName, diag::err_too_many_formals_in_macro_invoc);
+          Diag(MacroName, diag::err_too_many_args_in_macro_invoc);
           return 0;
         }
         // Otherwise, continue to add the tokens to this variable argument.
@@ -740,7 +740,7 @@
   
   // Okay, we either found the r_paren.  Check to see if we parsed too few
   // arguments.
-  unsigned NumFormals = Args->getNumArguments();
+  unsigned NumActuals = Args->getNumArguments();
   unsigned MinArgsExpected = MI->getNumArgs();
   
   // C99 expects us to pass at least one vararg arg (but as an extension, we
@@ -748,9 +748,9 @@
   // the count.
   MinArgsExpected += MI->isC99Varargs();
   
-  if (NumFormals < MinArgsExpected) {
+  if (NumActuals < MinArgsExpected) {
     // There are several cases where too few arguments is ok, handle them now.
-    if (NumFormals+1 == MinArgsExpected && MI->isVariadic()) {
+    if (NumActuals+1 == MinArgsExpected && MI->isVariadic()) {
       // Varargs where the named vararg parameter is missing: ok as extension.
       // #define A(x, ...)
       // A("blah")
@@ -768,7 +768,7 @@
         Diag(Tok, diag::ext_empty_fnmacro_arg);
     } else {
       // Otherwise, emit the error.
-      Diag(Tok, diag::err_too_few_formals_in_macro_invoc);
+      Diag(Tok, diag::err_too_few_args_in_macro_invoc);
       return 0;
     }
   }

Modified: cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=38717&r1=38716&r2=38717&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jul 11 11:24:03 2007
@@ -219,9 +219,9 @@
      "\"##\" cannot appear at end of macro expansion")
 DIAG(err_unterm_macro_invoc, ERROR,
      "unterminated function-like macro invocation")
-DIAG(err_too_many_formals_in_macro_invoc, ERROR,
+DIAG(err_too_many_args_in_macro_invoc, ERROR,
      "too many arguments provided to function-like macro invocation")
-DIAG(err_too_few_formals_in_macro_invoc, ERROR,
+DIAG(err_too_few_args_in_macro_invoc, ERROR,
      "too few arguments provided to function-like macro invocation")
 
 





More information about the cfe-commits mailing list