]> granicus.if.org Git - clang/commitdiff
refactor the interface to Preprocessor::GetIncludeFilenameSpelling,
authorChris Lattner <sabre@nondot.org>
Mon, 23 Jul 2007 04:15:27 +0000 (04:15 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 Jul 2007 04:15:27 +0000 (04:15 +0000)
no functionality changes.

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

Lex/Pragma.cpp
Lex/Preprocessor.cpp
include/clang/Lex/Preprocessor.h

index b1a569e546179cbdb750968cc6752964d1a813a7..4d90e31c643d50897551a1dba34f04f63ed154dc 100644 (file)
@@ -254,8 +254,10 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
   llvm::SmallVector<char, 128> FilenameBuffer;
   FilenameBuffer.resize(FilenameTok.getLength());
   
-  const char *FilenameStart = &FilenameBuffer[0], *FilenameEnd;
-  bool isAngled = GetIncludeFilenameSpelling(FilenameTok,
+  const char *FilenameStart = &FilenameBuffer[0];
+  unsigned Len = getSpelling(FilenameTok, FilenameStart);
+  const char *FilenameEnd = FilenameStart+Len;
+  bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(),
                                              FilenameStart, FilenameEnd);
   // If GetIncludeFilenameSpelling set the start ptr to null, there was an
   // error.
index ceab0ba1e7d7fb1ff33f4af961bea01cf8f91034..e6cb218b828d23bfdce31204ab150ff14261bdd7 100644 (file)
@@ -1584,39 +1584,37 @@ void Preprocessor::HandleIdentSCCSDirective(Token &Tok) {
 /// caller is expected to provide a buffer that is large enough to hold the
 /// spelling of the filename, but is also expected to handle the case when
 /// this method decides to use a different buffer.
-bool Preprocessor::GetIncludeFilenameSpelling(const Token &FilenameTok,
+bool Preprocessor::GetIncludeFilenameSpelling(SourceLocation Loc,
                                               const char *&BufStart,
                                               const char *&BufEnd) {
   // Get the text form of the filename.
-  unsigned Len = getSpelling(FilenameTok, BufStart);
-  BufEnd = BufStart+Len;
   assert(BufStart != BufEnd && "Can't have tokens with empty spellings!");
   
   // Make sure the filename is <x> or "x".
   bool isAngled;
   if (BufStart[0] == '<') {
     if (BufEnd[-1] != '>') {
-      Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+      Diag(Loc, diag::err_pp_expects_filename);
       BufStart = 0;
       return true;
     }
     isAngled = true;
   } else if (BufStart[0] == '"') {
     if (BufEnd[-1] != '"') {
-      Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+      Diag(Loc, diag::err_pp_expects_filename);
       BufStart = 0;
       return true;
     }
     isAngled = false;
   } else {
-    Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+    Diag(Loc, diag::err_pp_expects_filename);
     BufStart = 0;
     return true;
   }
   
   // Diagnose #include "" as invalid.
   if (BufEnd-BufStart <= 2) {
-    Diag(FilenameTok.getLocation(), diag::err_pp_empty_filename);
+    Diag(Loc, diag::err_pp_empty_filename);
     BufStart = 0;
     return "";
   }
@@ -1646,8 +1644,10 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
   llvm::SmallVector<char, 128> FilenameBuffer;
   FilenameBuffer.resize(FilenameTok.getLength());
   
-  const char *FilenameStart = &FilenameBuffer[0], *FilenameEnd;
-  bool isAngled = GetIncludeFilenameSpelling(FilenameTok,
+  const char *FilenameStart = &FilenameBuffer[0];
+  unsigned Len = getSpelling(FilenameTok, FilenameStart);
+  const char *FilenameEnd = FilenameStart+Len;
+  bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(),
                                              FilenameStart, FilenameEnd);
   // If GetIncludeFilenameSpelling set the start ptr to null, there was an
   // error.
index b4c64f1dcb777d78f2ddfc217e10e27f18463108..ff1faaa58c60e2b206966985f7d78722d1d305da 100644 (file)
@@ -409,7 +409,7 @@ private:
   /// caller is expected to provide a buffer that is large enough to hold the
   /// spelling of the filename, but is also expected to handle the case when
   /// this method decides to use a different buffer.
-  bool GetIncludeFilenameSpelling(const Token &FNTok,
+  bool GetIncludeFilenameSpelling(SourceLocation Loc,
                                   const char *&BufStart, const char *&BufEnd);
   
   /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,